Skip to content

Commit

Permalink
Version number, name, and build details.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 8, 2015
1 parent 6883d28 commit 1cb147c
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ TAGS
ccan/tools/configurator/configurator
libsecp256k1.a
libsecp256k1.la
gen_*
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/make
NAME=MtGox's Cold Wallet

# Needs to have oneof support: Ubuntu vivid's is too old :(
PROTOCC:=protoc-c
Expand All @@ -12,11 +13,11 @@ PROGRAMS := test-cli/open-channel test-cli/create-anchor-tx test-cli/open-commit

BITCOIN_OBJS := bitcoin/address.o bitcoin/base58.o bitcoin/pubkey.o bitcoin/script.o bitcoin/shadouble.o bitcoin/signature.o bitcoin/tx.o

HELPER_OBJS := lightning.pb-c.o pkt.o permute_tx.o commit_tx.o opt_bits.o close_tx.o find_p2sh_out.o protobuf_convert.o funding.o test-cli/gather_updates.o
HELPER_OBJS := lightning.pb-c.o pkt.o permute_tx.o commit_tx.o opt_bits.o close_tx.o find_p2sh_out.o protobuf_convert.o funding.o test-cli/gather_updates.o version.o

CCAN_OBJS := ccan-crypto-sha256.o ccan-crypto-shachain.o ccan-err.o ccan-tal.o ccan-tal-str.o ccan-take.o ccan-list.o ccan-str.o ccan-opt-helpers.o ccan-opt.o ccan-opt-parse.o ccan-opt-usage.o ccan-read_write_all.o ccan-str-hex.o ccan-tal-grab_file.o ccan-noerr.o ccan-crypto-ripemd160.o

HEADERS := $(wildcard *.h) $(wildcard bitcoin/*.h)
HEADERS := $(filter-out gen_*, $(wildcard *.h)) $(wildcard bitcoin/*.h)

CCANDIR := ccan/
CFLAGS := -g -Wall -I $(CCANDIR) -I secp256k1/include/ -DVALGRIND_HEADERS=1 $(FEATURES)
Expand Down Expand Up @@ -52,6 +53,12 @@ doc/deployable-lightning.pdf: doc/deployable-lightning.lyx doc/bitcoin.bib
doc/deployable-lightning.tex: doc/deployable-lightning.lyx
lyx -E latex $@ $<

gen_version.h: FORCE
@(echo "#define VERSION \"`git describe --always --dirty`\"" && echo "#define VERSION_NAME \"$(NAME)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new
@if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; fi

version.o: gen_version.h

update-ccan:
mv ccan ccan.old
DIR=$$(pwd)/ccan; cd ../ccan && ./tools/create-ccan-tree -a $$DIR `cd $$DIR.old/ccan && find * -name _info | sed s,/_info,, | sort` $(CCAN_NEW)
Expand All @@ -63,7 +70,7 @@ update-ccan:
$(RM) -r ccan.old

distclean: clean
$(RM) lightning.pb-c.c lightning.pb-c.h ccan/config.h
$(RM) lightning.pb-c.c lightning.pb-c.h ccan/config.h gen_version.h
$(RM) doc/deployable-lightning.pdf

clean:
Expand Down
2 changes: 2 additions & 0 deletions test-cli/check-commit-sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "bitcoin/privkey.h"
#include "protobuf_convert.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -37,6 +38,7 @@ int main(int argc, char *argv[])
"<open-channel-file1> <open-channel-file2> <open-anchor-file1> <commit-key1> [<commit-sig>]\n"
"Check the commit sig is valid (either in open-anchor or commit-sig packet)",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/close-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "opt_bits.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand Down Expand Up @@ -50,6 +51,7 @@ int main(int argc, char *argv[])
opt_register_arg("--close-fee=<bits>",
opt_set_bits, opt_show_bits, &close_fee,
"100's of satoshi to pay for close tx");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-anchor-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <unistd.h>
#include <time.h>
#include "opt_bits.h"
#include "version.h"

/* Bitcoin nodes are allowed to be 2 hours in the future. */
#define LOCKTIME_MIN (2 * 60 * 60)
Expand Down Expand Up @@ -92,6 +93,7 @@ int main(int argc, char *argv[])
opt_register_arg("--anchor-fee=<bits>",
opt_set_bits, opt_show_bits, &anchor_fee,
"100's of satoshi to pay for anchor");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-close-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -38,6 +39,7 @@ int main(int argc, char *argv[])
"<open-channel-file1> <open-channel-file2> <open-anchor-file> <close-protobuf> <close-complete-protobuf> [update-protobuf]...\n"
"Create the close transaction from the signatures",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-commit-spend-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "protobuf_convert.h"
#include "test-cli/gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand Down Expand Up @@ -49,6 +50,7 @@ int main(int argc, char *argv[])
opt_register_arg("--fee=<bits>",
opt_set_bits, opt_show_bits, &fee,
"100's of satoshi to pay in transaction fee");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-commit-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

/* FIXME: this code doesn't work if we're not the ones proposing the delta */
Expand All @@ -40,6 +41,7 @@ int main(int argc, char *argv[])
"<open-channel-file1> <open-channel-file2> <open-anchor-file> <commit-privkey> [<updates>]\n"
"Create the signature needed for the commit transaction",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-htlc-spend-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bitcoin/privkey.h"
#include "protobuf_convert.h"
#include "find_p2sh_out.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand Down Expand Up @@ -48,6 +49,7 @@ int main(int argc, char *argv[])
"Create a transaction which spends commit-tx's htlc output, and sends it P2SH to outpubkey\n"
"It relies on timeout, unless --rvalue or --commit-preimage is specified",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/create-steal-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "bitcoin/pubkey.h"
#include "bitcoin/privkey.h"
#include "protobuf_convert.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -37,6 +38,7 @@ int main(int argc, char *argv[])
"<commit-tx> <revocation-preimage> <final-privkey> <open-channel-file1> <open-channel-file2> <outpubkey>\n"
"Create a transaction which spends commit-tx's revocable output, and sends it P2SH to outpubkey",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/get-anchor-depth.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "bitcoin/pubkey.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -25,6 +26,7 @@ int main(int argc, char *argv[])
"<open-channel-file>\n"
"Prints anchor depth as contained in OpenChannel message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
1 change: 1 addition & 0 deletions test-cli/leak-anchor-sigs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int main(int argc, char *argv[])
"<open-anchor-sig-file>\n"
"Create LeakAnchorSigsAndPretendWeDidnt to stdout",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/open-anchor.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <unistd.h>
#include <time.h>
#include "opt_bits.h"
#include "version.h"

int main(int argc, char *argv[])
{
Expand All @@ -44,6 +45,7 @@ int main(int argc, char *argv[])
"<open-channel-file1> <open-channel-file2> <anchor-tx-file> <commit-privkey1>\n"
"A test program to output open_anchor message on stdout.",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/open-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <unistd.h>
#include <time.h>
#include "opt_bits.h"
#include "version.h"

/* Bitcoin nodes are allowed to be 2 hours in the future. */
#define LOCKTIME_MIN (2 * 60 * 60)
Expand Down Expand Up @@ -58,6 +59,7 @@ int main(int argc, char *argv[])
opt_register_arg("--commitment-fee=<bits>",
opt_set_bits, opt_show_bits, &commit_tx_fee,
"100's of satoshi to pay for commitment");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/open-commit-sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bitcoin/privkey.h"
#include "protobuf_convert.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -39,6 +40,7 @@ int main(int argc, char *argv[])
"<open-channel-file1> <open-channel-file2> <open-anchor-file1> <commit-privkey>\n"
"Create the signature needed for the commit transaction",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/txid-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <ccan/str/hex/hex.h>
#include <ccan/err/err.h>
#include "bitcoin/tx.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -22,6 +23,7 @@ int main(int argc, char *argv[])
"<tx>\n"
"Print txid of the transaction in the file",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -42,6 +43,7 @@ int main(int argc, char *argv[])
"<seed> <open-channel-file1> <open-channel-file2> <open-anchor-file> <commit-privkey> <all-updates...>\n"
"Accept a new update message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -40,6 +41,7 @@ int main(int argc, char *argv[])
"<seed> <open-channel-file1> <open-channel-file2> <open-anchor-file> <all-previous-updates>\n"
"Create a new update-complete message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-htlc-complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "commit_tx.h"
#include "bitcoin/pubkey.h"
#include "find_p2sh_out.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -29,6 +30,7 @@ int main(int argc, char *argv[])
"<seed> <update-number> <r-value>\n"
"Create a new HTLC complete message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-htlc-remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "bitcoin/pubkey.h"
#include "find_p2sh_out.h"
#include "protobuf_convert.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -31,6 +32,7 @@ int main(int argc, char *argv[])
"<seed> <update-number> <update-pkt>\n"
"Create a new HTLC remove message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-htlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "commit_tx.h"
#include "bitcoin/pubkey.h"
#include "find_p2sh_out.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -32,6 +33,7 @@ int main(int argc, char *argv[])
"<seed> <update-number> <satoshi> <r-value> <abs-locktime-seconds>\n"
"Create a new HTLC update message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel-signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "protobuf_convert.h"
#include "gather_updates.h"
#include "funding.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -42,6 +43,7 @@ int main(int argc, char *argv[])
"<seed> <open-channel-file1> <open-channel-file2> <open-anchor-file> <commit-privkey> <all-previous-updates>...\n"
"Create a new update-channel-signature message",
"Print this message.");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
2 changes: 2 additions & 0 deletions test-cli/update-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "commit_tx.h"
#include "bitcoin/pubkey.h"
#include "find_p2sh_out.h"
#include "version.h"
#include <unistd.h>

int main(int argc, char *argv[])
Expand All @@ -37,6 +38,7 @@ int main(int argc, char *argv[])
opt_register_arg("--from-them=<satoshi>",
opt_set_ulonglongval_si, NULL, &from_them,
"Amount to pay us (must use this or --to-them)");
opt_register_version();

opt_parse(&argc, argv, opt_log_stderr_exit);

Expand Down
11 changes: 11 additions & 0 deletions version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "version.h"
#include "gen_version.h"
#include <stdio.h>

char *version_and_exit(const void *unused)
{
printf("%s\n"
"aka. %s\n"
"Built with: %s\n", VERSION, VERSION_NAME, BUILD_FEATURES);
exit(0);
}
11 changes: 11 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef LIGHTNING_VERSION_H
#define LIGHTNING_VERSION_H
#include <ccan/opt/opt.h>

char *version_and_exit(const void *unused);

#define opt_register_version() \
opt_register_noarg("--version|-V", version_and_exit, NULL, \
"print version to standard output and exit")

#endif /* LIGHTNING_VERSION_H */

0 comments on commit 1cb147c

Please sign in to comment.