Commit Graph

472 Commits

Author SHA1 Message Date
Rusty Russell e44f951b6c Makefile: use -modded instead of -with-local-modifications
Since we include the tail of the version in the default aliasname with
DEVELOPER, we want to see more of it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-05-05 17:55:10 +02:00
Christian Decker 6139fee31d fixup! make: Disable DEVELOPER by default 2018-05-04 01:01:41 +02:00
Christian Decker 00e75fee0c make: Disable DEVELOPER by default
We had quite a few users running into issues because the `--dev-xyz` options and
`dev-xyz` RPC calls were available. Before a release we should make sure that
the default compilation flags are safe.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-05-04 01:01:41 +02:00
practicalswift abf510740d Force the use of the POSIX C locale for all commands and their subprocesses 2018-04-27 14:02:59 +02:00
Rusty Russell 5ff0d40fed travis: don't retry failing tests.
Retrying gives spurious failures, since we see transactions from previous
runs.  That makes it near impossible to diagnose the actual problem.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-23 20:18:15 +00:00
Rusty Russell a1cf7897c0 shellcheck: restore the check.
Accidentally disabled in 9c3691340f.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-07 23:38:03 +02:00
Rusty Russell 9c3691340f ccan: update to more recent version.
In particular, this gets some MacOS fixes from #1327.
It also includes a major intmap update which fixes corner cases in traversals,
and requires ccan/bitops.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-06 13:34:27 +02:00
practicalswift bc4a099bff Add shell script linting: Check for shellcheck warnings in shell scripts 2018-04-04 15:06:30 +02:00
practicalswift 66fc0a047b Make version output simpler/more user-friendly 2018-04-04 02:32:44 +00:00
practicalswift 760e9f6993 Add cppcheck checking as part of check-source 2018-03-29 23:16:03 +02:00
Rusty Russell a54872063f check-cppcheck: autogen suppressions for all the list_for_each(_safe)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-29 23:16:03 +02:00
practicalswift e078fcefdd Add check-includes.sh: Find redundant includes. Check ifndef:s. 2018-03-25 23:54:21 +00:00
Zhen Zhang d1010673b5 contrib: Rewrite contrib/lightning-pay in Python, support bolt11
fixes #718
2018-03-25 23:19:35 +02:00
Rusty Russell f2adb76d04 test: remove obsolete directory.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-16 00:16:10 +00:00
Rusty Russell 6da0861064 Makefile: add COMPAT_V052 define.
This lets us clearly mark transition features, in a way that they can
be removed after 0.6 is released.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-07 18:55:51 +01:00
Jan Sarenik 54b8562936 Fix libtool error
This is how the error before the fix looked like on Arch Linux with
GNU libtool 2.4.6.40-6ca5-dirty:

    $ make installcheck
    ...
    make[4]: Entering directory '/home/jasan/lightning/external/libwally-core/src/secp256k1'
     /usr/bin/mkdir -p 'testinstall/home/jasan/lightning/external/libwally-core/..'
     /bin/sh ./libtool   --mode=install /usr/bin/install -c   libsecp256k1.la 'testinstall/home/jasan/lightning/external/libwally-core/..'
    Usage: /home/jasan/lightning/external/libwally-core/src/secp256k1/libtool [OPTION]... [MODE-ARG]...
    Try 'libtool --help' for more information.
    libtool:   error: 'testinstall/home/jasan/lightning/external/libwally-core/..' must be an absolute directory name
    make[4]: *** [Makefile:910: install-libLTLIBRARIES] Error 1
    make[4]: Leaving directory '/home/jasan/lightning/external/libwally-core/src/secp256k1'
    make[3]: *** [Makefile:1253: install-exec-recursive] Error 1
    make[3]: Leaving directory '/home/jasan/lightning/external/libwally-core/src'
    make[2]: *** [Makefile:429: install-exec-recursive] Error 1
    make[2]: Leaving directory '/home/jasan/lightning/external/libwally-core'
    make[1]: *** [external/Makefile:41: external/libwallycore.a] Error 2
    rm external/libwally-core/src/secp256k1/libsecp256k1.la
    make[1]: Leaving directory '/home/jasan/lightning'
    make: *** [Makefile:430: installcheck] Error 2

Then there was linking error which needed to be fixed by correcting
the idea of installing external libraries to a particular directory.
2018-02-28 01:53:33 +00:00
Rusty Russell fba2bdb0ec ccan/config.h: make it depend on the top-level Makefile.
This way if the argument change, it will be regenerated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-26 15:01:02 +01:00
Rusty Russell 229f288eb5 Makefile: allow configurator to use a different CC, by setting CONFIGURATOR_CC
This should solve what @icota wanted in https://github.com/ElementsProject/lightning/pull/1035 in a much cleaner way.

In particular, this allows you to say what configurator should use, independent
of what other compilation should use, and reverts the '-static' which broke
MacOS.

Fixes: #1059
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-26 15:01:02 +01:00
practicalswift fd4a36e777 Add "make check-python" 2018-02-26 12:38:00 +01:00
Christian Decker da062df594 make: If running on travis allow 3 reruns of failed tests
This may mask a few flaky tests, but cuts down on the manual reruns.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-24 10:40:03 +01:00
arowser 73fab9e345 move library path to LDLIBS 2018-02-23 21:49:00 +00:00
Igor Cota d4d1c4acb0 Add PIE option to Makefile to build position independent executables
As of version 5.0 Android requires all dynamically linked executables to support PIE. This allows programs to be loaded at a different addresses, making it harder for attackers to target.
Enable with PIE=1
2018-02-20 03:55:53 +00:00
Igor Cota bd95aba7a5 Pass the compiler variable to the configurator executable when building ccan/config.h
When cross compiling it's important that the resulting config.h reflects the platform we are building for and not the one we are building on.
Otherwise we end up with a config.h that defines headers that are not there on the target platform, wrong endnianness and so on.
The -static flag is there to be able to easily run the configurator test executables on the build machine with qemu-*.
E.g. Without the -static flag the resulting dynamically linked ARM executables complain about the lack of linker (/lib/ld-linux-armhf.so or /system/bin/linker for Android), since these files are not usually available on the build machine building statically avoids this problem and results in a proper config.h for cross compiling.
2018-02-20 03:18:11 +00:00
Rusty Russell 237a65d000 ccan: add tal/link.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-19 02:56:51 +00:00
Rusty Russell c5cc5c5c1b ccan: import ccan/daemonize.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-16 13:02:41 +01:00
practicalswift 3e40a48332 Add lightning spell check 2018-01-26 01:02:15 +00:00
Carl Dong f55adbdc9c build: Add necessary build/link flags for FreeBSD. 2018-01-23 16:10:19 +01:00
Carl Dong 75f4b56766 build: Correctly build and link ptr_valid. 2018-01-23 16:10:19 +01:00
Rusty Russell 2ff9e42b33 lightning-cli: fix amazingly slow getlogs speed.
real	0m0.380s
user	0m0.331s
sys	0m0.028s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-22 18:58:23 +01:00
Rusty Russell c22d2c8dae Makefile: rebuild all objects if Makefile changes.
This doesn't cover external libs in general (which *could* be effected by
CFLAGS), but at least all our own objects are rebuilt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-22 18:58:23 +01:00
practicalswift a08b6fffc6 Add consistency check for dependencies listed in README.md and doc/INSTALL.md 2018-01-19 10:11:19 +00:00
ZmnSCPxj 72841056f5 Makefile: Install subdaemons into pkglibexecdir instead of bindir.
Fixes: #434
2018-01-09 14:52:48 +01:00
ZmnSCPxj 1946f0c288 Makefile: Add BINTOPKGLIBEXECDIR macro. 2018-01-09 14:52:48 +01:00
ZmnSCPxj bba8a3cab7 Makefile: Add installcheck target to check installation procedure. 2018-01-09 14:52:48 +01:00
ZmnSCPxj e559f2cb2e Implement "install" and "uninstall" targets for Makefile.
Fixes: #383
2018-01-09 14:52:48 +01:00
William Casarin a1d215a46d make: append contrib/pylightning to PYTHONPATH
Append contrib/pylightning instead of overriding PYTHONPATH for tests.

Signed-off-by: William Casarin <jb55@jb55.com>
2018-01-03 22:25:00 +00:00
Christian Decker ab620c5068 travis: Enable pytest-test-groups to split tests across several runs
Adds two new environment variables TEST_GROUP_COUNT and TEST_GROUP to
split the integration tests into groups and run only a selected group.

This allows us to increase the TEST_GROUP_COUNT and add a new
TEST_GROUP to avoid bumping up against the time limit when running in
valgrind.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-21 22:43:24 +00:00
Rusty Russell 95df553813 lightningd: add dev-memdump command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-20 12:43:10 +01:00
practicalswift 61c47c09d0 Fix typos 2017-12-08 13:07:20 +01:00
Rusty Russell af7e6158af Makefile: clean needs to do more, distclean should remove everything.
I checked this with git status --ignored after a full build and 'make distclean'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:29:03 +01:00
Rusty Russell 1648eb548a devtools/bolt11-cli: simple helper to decode bolt11.
Can be extended to encode later, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00
Rusty Russell 88ec8df329 bitcoin/scripts: use htlckey instead of localkey.
Basically a namechange in the argument list.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-16 17:40:57 +01:00
Rusty Russell 44e45348f2 option-data-loss-protect: fix generate-wire.py and update.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-16 15:26:41 +01:00
Christian Decker fc176b6cc0 pytest: Use the py.test utility if available
The py.test unit test runner offers a number of more advanced features
than simply running using unittest.main. In particular it allows us to
capture a tests output and print it if it fails. This change checks
whether we have pytest available and if yes, enables verbose tests and
runs using pytest. This'll give the usual experience (with colors!)
and show us the stdout if a test fails making travis a lot easier to
handle.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-10 02:20:00 +00:00
Rusty Russell 1ae57fb72c Update to latest BOLT.
Nothing changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-01 09:46:05 +01:00
Rusty Russell a9002eac52 Update to latest BOLT.
And nail "make check-source" to that specific version (which is a commit id,
not a branch name, so needs a different syntax for git).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-01 01:09:23 +00:00
Rusty Russell 45b92dc2b0 pytest: pass DEVELOPER flag through.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-31 04:14:33 +00:00
Rusty Russell 3c6eec87e3 Add DEVELOPER flag, set by default.
This is a bit messier than I'd like, but we want to clearly remove all
dev code (not just have it uncalled), so we remove fields and functions
altogether rather than stub them out.  This means we put #ifdefs in callers
in some places, but at least it's explicit.

We still run tests, but only a subset, and we run with NO_VALGRIND under
Travis to avoid increasing test times too much.

See-also: #176
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-26 12:53:09 +02:00
Rusty Russell 9e869e641a take: turn labels on.
Gives us meaningful errors when there's a take() leak.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-25 18:34:35 +02:00
Rusty Russell ebba5f85a2 handshaked: remove.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-20 18:31:32 +02:00
Rusty Russell 7200002773 tests: detect and close leaks in unit tests.
Fixes: #288
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-09-29 10:20:08 +09:30
Rusty Russell dfa062b06a Makefile: make default correctly build $(ALL_PROGRAMS) and $(ALL_TEST_PROGRAMS).
We can't reference the variables until after they're set, so hence the
two-step.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-09-11 14:29:20 +02:00
Christian Decker 47a7fac29f make: Add cli/lightning-cli to default make target
Closes #270

Reported-by: @sumBTC
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-09-11 14:29:20 +02:00
Rusty Russell 8a829ba9cb update-mocks: move mock generation into tools/, fix and generalize.
update-mocks was broken, since it assumed the daemon/ directory.

We now use "make" directly to build the test file and harvest errors,
and are more robust if it simply doesn't compile (ie. fails, but no
linker errors).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-09-03 02:01:54 +02:00
Rusty Russell bbed5e3411 Rename subdaemons, move them into top level.
We leave the *build* results in lightningd/ for ease of in-place testing though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 739b163f8b Makefiles: simplify dependencies.
Gather all binaries and objects and make the depend on external
requirements and common headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell f42f34b82d external: new subdirectory for all external libraries and submodules.
You will want to 'make distclean' after this.

I also removed libsecp; we use the one in in libwally anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell c6976cd947 shachain: always build 48 bit version.
No more special Makefile hacks required.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell a37c165cb9 common: move some files out of lightningd/
Basically all files shared by different daemons.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 8375857116 common: absorb remaining files from daemon/
Also, we split the more sophisticated json_add helpers to avoid pulling in
everything into lightning-cli, and unify the routines to print struct
short_channel_id (it's ':',  not '/' too).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 85ff95e829 common: new directory for any shared objects.
To avoid everything pulling in HTLCs stuff to the opening daemon, we
split the channel and commit_tx routines into initial_channel and
initial_commit_tx (no HTLC support) and move full HTLC supporting versions
into channeld.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 660c051068 opt_bits: remove.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell e7e43cf9a5 remove_dust: remove.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 8088e5cadb protobuf: remove
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 2013906798 find_p2sh_out: remove.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 9ef34d01de irc: remove files.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 88bb38f63b daemon/lightningd: remove building, and main files
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 26ffa8fdec check-bolt: move to tools/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-22 14:56:02 +02:00
Christian Decker fa6e53bb08 Move short_channel_id primitive into bitcoin
Not really a bitcoin primitive but the place where we keep all the
small stuff currently.
2017-08-10 12:34:58 +09:30
Christian Decker df056e5973 bitcoin: Added chainparams grouping blockchain specific parameters 2017-07-12 11:30:23 +09:30
Rusty Russell 7dce850844 Makefile: wallet objects depend on sodium headers, too.
Noticed a build failure from a fresh git clone.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Christian Decker a53acb7877 make: Explicitly set cc compatibility
This is apparently necessary to build `lightningd` on debian jessie,
which uses an older gcc version.
2017-07-07 10:15:02 +02:00
Rusty Russell 122598dffc Makefile: use -f with pytest, to exit on first failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-06-23 09:29:42 +09:30
Christian Decker 80436d06cb wallet: Create and manage a sqlite3 database for the wallet 2017-06-06 09:16:10 +09:30
Rusty Russell f61da7eb64 tests/test_lightningd.py: incorporate everything from old test-basic shell test.
This moves all the non-legacy blackbox testing into python.

Before:
	real	10m18.385s

After:
	real	9m54.877s

Note that this doesn't valgrind the subdaemons: that patch seems to cause
some issues in the python framework which I am still chasing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Rusty Russell 0e6667f3b2 pytest: fix dependencies
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Christian Decker 67315be673 travis: Simplified build script
The Dockerfile is now stored in contrib and built using the Docker
Hub. This allows us to simply pull in the finished image from the hub
instead of having to build it ourself. Should shave off about 2
minutes from the build time.

I also switched to running the individual build and check steps in
their own containers, but on the same volume, so travis can group the
commands and run them independently.
2017-04-29 10:29:44 +09:30
Christian Decker e603dba14a sphinx: Fixing makefile for test_sphinx and using lightningd version 2017-04-28 13:40:43 +09:30
Rusty Russell 27764b65f9 lightningd: fix shachain to be 48-bits, with hack for legacy.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell 4bf398c4e7 status: move into lightningd/status.
It's really a lightningd-only thing, and we're about to do surgery on it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-20 07:50:53 +10:30
Rusty Russell c6f568dbde Makefile: fix distclean, clean targets.
libwally's tools/cleanup.sh doesn't actually remove files if it can't
run make, so do that manually.  Also clear some other cruft.

Also, we weren't deleting wire/gen_onion_wire.c in "make clean".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-02 22:51:39 +10:30
Christian Decker 7ac7a6a47e cleanup: Ignoring libwally artifacts and distclean cleans them 2017-02-27 23:14:43 +01:00
Rusty Russell fb93503e6d Makefile: fix libsodium build
eg:
	gcc: error: libsodium.a: No such file or directory

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell 1271ac8899 libwally-core: import version 3b025127cbf11912f8b95e7ff3c905d74e8433ce
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell c6997f15c7 bitcoin/preimage: struct preimage.
We had a hack for 'struct rval' in protobuf_convert.h; make an
explicit header and put it in bitcoin/preimage.h.  It's not really
bitcoin-specific, but it's better than having bitcoin/script depend on
an external header.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell a02f1e10c4 make check: run all the tests.
We can't run them in parallel, but we can at least have 'make check'
run them all.

Developers should be running "make check-source && make check".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Christian Decker 05cf3160d4 ccan: Added ccan/intmap 2017-02-02 11:29:47 +10:30
Christian Decker 7cc5e2fc7a pytest: Added pytest target to Makefile 2017-01-23 10:45:36 +10:30
Rusty Russell 69079e51a9 doc: move Makefile parts into doc/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-23 10:38:42 +10:30
Rusty Russell df59cef3af doc: rename waitinvoice manpage to waitanyinvoice.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-23 10:28:32 +10:30
Rusty Russell 73d07ce441 libsodium: use our local submodule.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-11 10:04:26 +10:30
Rusty Russell 015eb072b8 Makefile: split CORE_SRC into CORE_SRC, CORE_TX_SRC and CORE_PROTOBUF_SRC
With the lightningd daemon split, we don't need them all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 8bf33c7839 lightningd/lightningd: daemon for controlling the other daemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:37:51 +10:30
Rusty Russell a0ac5c276e status: API for status reporting.
The API formalizes how daemons should report their statuses back to
the main lightningd.  It's a simple write API, which includes tracing
support (currently it always sends traces, later it could send iff
there's a failure, for example).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:24:20 +10:30
Christian Decker 07fbeee29d coverage: Added `coverage` makefile target
Added coverage files to `clean` and `coverage` target to generate HTML
report of coverage.
2017-01-10 09:27:55 +10:30
Christian Decker bd6b9c377e coverage: Enable compilation with `--coverage`
Setting the environment variable `COVERAGE=1` allows us to turn
coverage measurements on. This produces a number of auxiliary gcno and
gcda files which can then be converted into coverage reports.

I know line coverage and branch coverage is not a perfect metric, but
it might get us some more visibility into where more tests might be
needed.
2017-01-10 09:27:55 +10:30
Rusty Russell a6f98ad02b Makefile: wire objects also depend on CCAN headers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-05 12:11:18 +10:30
Rusty Russell 9df0aa7538 libbase58: add autosubmodule rule, move depends to bitcoin/Makefile
The object file should not be built inside the submodule, as that can
confuse git.

Not everything depends on the libbase58 header (CCAN doesn't), so
move that to the everything-else depends line.

The BITCOIN_SRC etc should also move to bitcoin/Makefile, but that's
a bigger change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-05 12:11:18 +10:30
Lucas Betschart 3e6bb958eb Add libbase58 as git submodule
Pointing to the latest release (0.1.4)
2017-01-05 12:11:18 +10:30
Rusty Russell a08a2105ea generate-wire.py: generalize, move to tools.
We're going to want to use this for inter-daemon comms, so generalize it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell b7789bf065 Makefile: generalize whitespace check.
Spread to individual Makefiles, and include headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell 751a0ae5cf check-whitespace: make it quieter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell 0861ec33a5 check-source-bolt: generalize.
This way sub-Makefiles can add their own files to check.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell b4f495fe99 check-source-bolt: don't try to check out if BOLTVERSION is empty or unset.
This lets you test against your local version, using:

	make check-source BOLTVERSION=

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell 6dc7056625 check-bolt: use new BOLTs.
The structure is slightly different, so this requires some fixes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell 05feefbb8a test: move mockup script outside daemon/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell d30b67a3fe test: generalize update-mocks
So we can use it in other directories.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:20 +10:30
Rusty Russell f8eb454139 type_to_string: move pretty printing of types from log
It's not just useful for logging.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:05:15 +10:30
Rusty Russell 59ecb3dfea Makefile: don't include tests in TAGS.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 13:17:47 +10:30
Rusty Russell f8344baf64 ccan: update, new modules.
ccan/autodata, ccan/breakpoint, ccan/crypto/hmac_sha256, ccan/crypto/hkdf_sha256,
ccan/fdpass and ccan/io/fdpass.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 13:16:47 +10:30
Rusty Russell 1f447688bc test: make generic driver for unit tests.
Not just in daemon.  This fixes 'make check' when it tries to
run 'make wire-tests'

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-02 18:10:13 +10:30
Christian Decker e40509c6c3 wire: Linking against wire objs 2016-12-01 13:50:02 +10:30
Rusty Russell 36e018161f wire: generate marshal/unmarshal from spec.
Including tests!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-01 13:50:02 +10:30
Rusty Russell f85f2c6c2d 0.5.2: Fixes and change IRC server.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-21 10:39:13 +10:30
Rusty Russell 88837c20ca Makefile: pass CC through to libsecp256k1 build.
For CC="gcc -m32" in particular.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 13:59:20 +10:30
Rusty Russell 0d7f6ce25b check-whitespace: add to check-source.
We don't check submodules (daemon/jsmn), or imported files (ccan/ secp256k1/)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:36:10 +10:30
Rusty Russell f5c00deec7 Remove trailing whitespace from source.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:32:04 +10:30
Rusty Russell 98910c03f2 check-source: add version to BOLTDIR.
This allows us to have different rfcs in different branches, which we're
going to need soon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:12:39 +10:30
Rusty Russell 700c536a27 Makefile: remove all the old Elements Alpha support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:30:35 +10:30
Rusty Russell d77d5edc07 Makefile: clean gen_ files and ccan/config in make clean.
Not on maintainer-clean; they don't need special tools.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell 49809785ca state.h state_types.h: move into daemon/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell fd6c3ce5a3 names: move into daemon/
It was already only referred from that Makefile.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell ec072b5d68 gen_pkt_names, gen_state_names: move into daemon/
That's where they're used.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell e40f864567 lightning.pb-c.c lightning.pb-c.h: don't generate if unchanged.
Just like man pages, git can mess us up here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 22:00:55 +10:30
Rusty Russell 6da448b797 0.5: Bitcoin Savings & Trust Daily Interest
Glenn Willen filed plenty of bug reports; he got to name this release.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-19 12:12:26 +10:30
Christian Decker d30f3f1a40 sphinx: Remove obsolete onion implementation 2016-10-16 16:40:54 +02:00
Christian Decker 7bb5c279a8 sphinx: Implemented sphinx onion routing
Implements a spec-compliant sphinx onion routing format. The format has
been cross-checked with the go implementation
cdecker/lightning-onion@b9e117e.
2016-10-16 16:40:43 +02:00
Rusty Russell 766249ec2b Makefile: don't regenerate manpages unless they've really changed.
This is terribly ugly :(

Closes: #36
Reported-by: Glenn Willen
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 13:57:57 +10:30
Rusty Russell 4fcdf6de5c irc: fix check-source.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 13:56:57 +10:30
Rusty Russell 5b3bde715a getinfo: add version information
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-14 05:28:51 +09:30
Rusty Russell c648897695 Makefile: clean up ccan-enumstr object for make clean.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-08 15:57:33 +09:30
Rusty Russell 2452df315a doc: manpages for the various lightning RPC calls.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:41 +09:30
Rusty Russell 678df3525e ccan: update, add cppmagic.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 13:47:07 +09:30
Rusty Russell af8e4ed2b9 ccan: remove unused modules.
These tal submodules got pulled in initially by an overzealous copy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-31 16:11:17 +09:30
Rusty Russell c11c81a920 daemon: first unit test, infrastructure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-25 11:39:46 +09:30
Rusty Russell 8d2776376a 0.4: Wright's Cryptographic Proof
Christian Decker moved us to libbase58 and off openssl; he got to name
this release.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-19 11:13:10 +09:30
Rusty Russell 190b30e958 daemon: test restarting.
We add a "dev-restart" command which causes the daemon to close fds
and exec itself.  Then we do it after every command, with the caveat
that we always send a commit before newhtlc, because if not committed,
that is forgotten.  Fulfillhtlc and failhtlc get resent, since they're
idempotent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:14 +09:30
Rusty Russell 71b8a07c56 db.c: database API.
These tables could use a rework, as they largely reflect our internal
state.  But it's a start.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:13 +09:30
Rusty Russell 3866d7605c daemon: reconnect support.
To do this we keep an order counter so we know how to retransmit.  We
could simply keep old packets, but this is a little clearer for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:08 +09:30
Rusty Russell 23f9c7c209 permute_tx: don't save permutation map.
We no longer need it anywhere.  This simplifies things to the point where
we might as well just not include dust outputs as we go, rather than
explicitly removing them, which gets rid of remove_dust.c as well.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:23:46 +09:30
Rusty Russell 809caa8588 bitcoin/pullpush.[ch]: expose bitcoin-style marshal/unmarshal.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:23:45 +09:30
Rusty Russell ca142a0b47 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> 2016-08-18 14:23:45 +09:30
Rusty Russell 748f477508 maintclean: fix depends and typo
Make CORE_OBJS depends on headers, also make them depend on CCAN headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-09 13:11:13 +09:30
Christian Decker 7546fad324 Removing OpenSSL as a dependency. 2016-08-09 13:10:19 +09:30
Christian Decker 1f4a056009 Switched base58 to use libbase58. 2016-08-09 13:10:19 +09:30
Rusty Russell c649f62e43 libsecp256k1: update.
Add Makefile target update-secp256k1, and run it.

The only API change is that len is now an IN-OUT parameter to serialization
functions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell de90b44bf6 Makefile: erase libsecp results on distclean.
If upgrade changes configure flags, 'make distclean' can fail as it
tries to reconfigure.  Deleting secp256k1/libsecp256k1.la forces a
full autogen/configure/make cycle.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell 42bed80145 pubkey: don't carry around DER encoding.
We just wrap the libsecp256k1 structure, and convert to DER on demand.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell fecd91ab2a Move funding.[ch] to daemon/channel.[ch].
It's a more logical name, and a more logical place.  We change
"funding" to "channel" in the remaining exposed symbols, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell 04b3e8f91d daemon: use siphash for hashes.
Remove ccan/hash (aka Jenkins lookup3) altogether.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell d1416ea5b5 TAGS: don't go into git dirs.
Things get quite confusing when this happens.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 11:59:15 +09:30
ocinq bcdab60694 Makefile : ccan/asort is referenced
Added explicit compilation and linking of ccan/asort as needed by daemon/chaintopology
2016-06-14 17:25:07 +02:00
Rusty Russell 49ebed737d daemon/test: test differential fees.
This would have revealed the previous breakage (and I tested that!),
plus now we test negotiate on closing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-30 11:18:46 +09:30
Rusty Russell 9bb070f5b6 0.3 release: Braydon Fuller: Nakamoto's Genesis Coins
Braydon wrote the INSTALL.md file; he gets to name this release,
in line with the theme.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-26 15:25:25 +09:30
Rusty Russell 97bc4ed0cb daemon/test: test mutual close with outstanding HTLCS.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-26 15:25:24 +09:30
Rusty Russell f43cc72d6a Makefile: add generated packet names.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-26 15:25:24 +09:30
Rusty Russell e46a2ed49a test/test_protocol: rename internally to match updated 02-wire-protocol.md
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 15:06:12 +09:30
Rusty Russell 06d2c19c41 test/test_protocol: make pretty(-ish) SVG diagrams.
Could make them much prettier, but they're functional.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 15:02:08 +09:30
Rusty Russell c710a64ccf Makefile: support for suppressing valgrind.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:49:54 +09:30
Rusty Russell 7f90d183da test/test_protocol: simulator for the updated wire-protocol BOLT.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:47:44 +09:30
Rusty Russell 35d1b13cde daemon: commit outstanding changes via timer.
While useful for testing, it doesn't make sense to have an explicit commit
command; we should commit whenever there are outstanding changes.

We have a 10ms timer to allow limited batching, however.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-10 06:30:11 +09:30
Rusty Russell 4beaedfa49 daemon/test: clean up Makefile.
This means mkae tells us directly what failed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-06 16:22:47 +09:30
Rusty Russell d6603adc2f daemon/test: test stealing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-06 12:00:30 +09:30
Rusty Russell 623eec4068 daemon/test: test unilateral close.
We use dev-disconnect to convince one node the other has disconnected
(but not vice versa), to get deterministic behaviour.  We do this with
one HTLC outstanding, to test the HTLC timeout path.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-04 16:14:22 +09:30
Rusty Russell f29a6043d2 daemon: open-code handling of on-chain states.
Once we see an on-chain tx, we ignore the state machine and handle it
as per the onchain.md draft.  This specifies a *resolution* for each
output, and we're done when they're irrevocable.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-04 16:14:22 +09:30
Rusty Russell 3f374d8d8b check-bolt: handle references to early-drafts too.
Particularly for the onchain.md draft.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-04 16:03:04 +09:30
Rusty Russell 9eabab78ab utils: tal_hexstr() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-03 11:28:49 +09:30
Rusty Russell a150bd191a remove_dust: don't ever create dust outputs.
This behavior will be specified in BOLT #3.

Closes: #14

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-03 11:28:49 +09:30
Rusty Russell 4bbb86ae30 daemon: clean up test dirs.
Move final helpers out of test-cli/

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-03 11:27:56 +09:30
Rusty Russell 03a538ca02 check-bolt: check that comments in code match the specs.
And fix the mistakes!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-03 11:27:56 +09:30
Rusty Russell 5ba7692254 Makefile: fix config.h rebuilds in parallel.
Occasionally make seems to rebuild this in parallel, so make sure to
never have a partially complete one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-03 11:27:56 +09:30
Rusty Russell e7b9a913a6 bitcoind: getrawblock helper.
It turns out using the verbose=false parameter, you can get the raw block
from getblock.  Do that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-24 19:40:29 +09:30
Rusty Russell 410fc3b272 misc: remove some unused functions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-24 19:33:13 +09:30
Rusty Russell 6b956ea22a varint: new file.
Move varint handling from tx.c and generalize it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-12 13:07:03 +09:30
Rusty Russell ed70b13041 bitcoin: add first unit test.
Should grow from here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-11 16:42:53 +09:30
Rusty Russell f8796c261b Make BIP68 and CSV support the default.
This has gone upstream into bitcoind, so enable it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-11 16:35:29 +09:30
Rusty Russell 8104886503 Remove Alpha support.
I had already disabled it, and this clears the decks for Segregated Witness
which gives us everything we want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-11 16:32:43 +09:30
Rusty Russell 18a9e5bda2 daemon: Implement encryption as per BOLT #1.
This uses libsodium (we could use openssl, but the required primitives
are only in 1.1.0 which is still in alpha).

It doesn't handle reconnections yet, either.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-16 16:06:17 +10:30
Rusty Russell 64e5ce1530 test: remove test_state_coverage
We're going to change the protocol to send multiple changes at once, so
disable this compilation and testing for now.

We can revisit it afterwards once the protocol is stable again.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-15 17:07:31 +10:30
Rusty Russell 09358498cd Remove test-cli
We're about to change the protocol again, and I don't want to do the
grunt work to update these.  They were useful for pre-build protocol
testing, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:37:15 +10:30
Rusty Russell b280cab6b0 Makefile: clean daemon files with make clean.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:32:15 +10:30
Braydon Fuller e0c4d40899 doc: add install notes 2016-02-24 23:59:33 -05:00
Rusty Russell 6750794667 Use #if instead of #ifdef (we already use -Wundef).
This avoids embarassing typos in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-27 15:00:50 +10:30
Rusty Russell 1e93da5513 Really enable checklocktimeverify support.
Next patch will make sure this never happens again.

Fixes: #18
Reported-by: Fabrice
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-27 14:52:30 +10:30
Rusty Russell d3455e7c22 Add brief HACKING.md, and update name.
Each release gets names by a new contributor: this one thanks to
Anthony Towns!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:49:47 +10:30
Rusty Russell b70c18a40e daemon: implement anchor watch timeout.
We abort when this happens, but still worth testing.

This involves a refactor so we can allocate watches off a specific context,
for easy freeing when they're no longer wanted.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:45:28 +10:30
Rusty Russell f5538bd1d2 daemon: test scripts.
We comment out the peer_create_close_tx() abort for now, so we
can test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:45:27 +10:30
Rusty Russell 378dadc371 daemon: configuration directory (default ~/.lightning).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:48 +10:30
Rusty Russell 117cf6b02d daemon: add logging options.
Particularly logging to file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell 3e77c55a3b Makefile: add daemon source sanity checks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell dd35260ce8 daemon: first code.
Logging code based heavily on pettycoin's.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell caa27f1d93 names.h/names.c: wrappers to get name for states/inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell e6dfff3ba8 licensing: Make license explicit.
Note that we're BSD-MIT but some of the ccan modules are different
licenses.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell 3a803eefbb bitcoin/tx: move bitcoin_tx_from_file() to test-cli, expose bitcoin_tx_from_hex()
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell 888389e625 ccan: update and add more.
We need the following additional modules for the daemon:
	io, time, timer, pipecmd

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell 906a5e4a32 Move pkt.c into test-cli.
We use cryptopkt for normal cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell a38d0c985e Makefile: more fascist warnings.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:37 +10:30
Rusty Russell 4163935bbb ccan: import time module.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell e97e8988f8 ccan: import isaac and dependencies.
We could probably just use Openssl's RAND_pseudo_bytes, but this gives
a nice interface to get a number between 1 and N.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell 4795a4d46f Makefile: sanity check source and makefile
This enforces the include order implemented by the previous patch, and
also make sure we haven't missed any headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell 4dafeba857 Makefile: depend on headers.
A halfway house between the horror of dynamic generation and the fail of
making everything depend on every header.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell ffe20fb2ae bitcoin: add OP_CHECKLOCKTIMEVERIFY support (BIP65)
No need to use noops now that BIP65 is active.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell aeedafc20f Switch to bitcoind by default.
I haven't implemented getting transactions from alphad (it needs the values
for the inputs, too), so switch to bitcoind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 4b02c6f558 locktime: nice abstractions for absolute and relative locktimes.
I got confused navigating these, especially since Alpha and Bitcoin
have diverged (BIP68 was proposed after Elements Alpha).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 45e0ab11ff Merge branch 'onion' 2016-01-22 06:35:11 +10:30
Rusty Russell 6b2d844f2a bitcoin: use ccan/mem instead of rolling own check_mem function.
Reported-by: John Newbery
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-26 21:06:23 +10:30
Anthony Towns b66852f1ab Makefile: add python onion tests 2015-10-06 23:49:52 +10:00
Anthony Towns 2042e1cdb7 onion_key: generate multiple keys at once 2015-10-06 23:49:52 +10:00
Rusty Russell ed46dd355d test_onion: split encode and decode, drive from cmdline.
This lets us test interaction with python code, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:53 +10:30
Rusty Russell 32a08ce6c5 test/onion_key: helper to generate deterministic key pairs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:09 +10:30
Rusty Russell f36ba8f8e1 Makefile: only erase protobuf and PDF files with maintainer-clean.
Reported-by: Anthony Towns
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell 81d35294f4 test/test_onion: demo program to show onion routing crypto.
We can make this more efficient, but this works for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell e7856e6e69 Update libsecp to git@github.com:bitcoin/secp256k1.git 52fd03f
We want the ecdh stuff for onion routing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:37:21 +09:30
Rusty Russell 17f457568a Makefile: generate libsecpk1 properly.
And clean it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:54 +09:30
Rusty Russell 454a3867e5 BIP68 support (nSequence enforcement)
The latest version of the BIP doesn't use inversion, but does use
bitshifts.

It also uncovered a bug in the test scripts: the block timestamps
creep forward when we generate large numbers of blocks (UpdateTime
insists it be > GetMedianTimePast() so it's valid).  We need to take
this into account when waiting for the median to move (reduced it from
60 to 30 seconds, since that adds about 14 seconds).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:11 +09:30
Rusty Russell 845d09ce68 check: simple Makefile target.
This makes it much easier to run all the test scripts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-29 17:02:02 +09:30
Rusty Russell 786bef9002 test/test_state_coverage: output dot format.
Good for documentation, plus impressive with all the error states...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 1556315f2e test_state_coverage: simple exhaustive coverage test for state machine.
Makes sure that we visit every state.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 5730b118f1 Some more ccan objs.
These are LGPL, but only used for tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 669479b671 gen_state_names.h: printable names for state_types enums.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 8af4619406 Makefile: neaten
Reduces gratuitous patch conflicts in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:03:20 +09:30
Rusty Russell 1cb147c5b8 Version number, name, and build details.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 20:45:49 +09:30
Rusty Russell fcbba0280d test-cli/create-htlc-spend-tx: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 16:20:45 +09:30
Rusty Russell b5ff69e236 test-cli/update-channel-htlc-remove: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:15:01 +09:30
Rusty Russell 9b0ed51f2b test-cli/update-channel-htlc-complete: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:14:46 +09:30
Rusty Russell 5778b004dd test-cli/update-channel-htlc: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:35 +09:30
Rusty Russell cf3433a0ad script: add OP_CHECKLOCKTIMEVERIFY.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell eac3af06f1 protocol: switch to single-funder anchor model.
Most complex change was gather_updates(), which handles all the "what
is the current state of the channel" logic for our dumb test utils.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-29 16:14:28 +09:30
Rusty Russell ee3af28980 test-cli/txid-of: simple helper to get txid.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-24 16:00:10 +09:30
Rusty Russell bde07aa6a7 Makefile: fix make clean, depend on bitcoin/ headers.
Didn't remove program object files, nor depend on all headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-24 16:00:10 +09:30
Rusty Russell e4921b9bc6 Add documentation.
First up, a draft of a paper showing the differences between the LN draft
and this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-18 10:46:53 +09:30
Rusty Russell 8f64eb90af Switch over to CCAN's ripemd160.
Avoids handing naked u8 arrays around, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09 15:43:36 +09:30
Rusty Russell ec399e13a4 Makefile: update-ccan: new target.
Hacky, but syncs up ccan repository.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09 15:25:09 +09:30
Rusty Russell a663dc322c Remove signature leaking.
Alpha has segregated witnesses, so txid doesn't include the inputs.
That means we can create the first commit transaction before we sign
the anchor tx.

Bitcoin will need to do this differently: presumbly via new sipops
(a OP_CHECKSIG2VERIFY I imagine).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-03 14:00:54 +09:30
Rusty Russell f510e29e22 alpha: switch over to Elements Alpha by default.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-03 13:36:25 +09:30
Rusty Russell 62a002c860 script: make DER for signature encoding optional.
Alpha does the sane thing, places signatures raw.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30
Rusty Russell faae91f3fc Schnorr signature support.
This variation is used by alpha.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30
Rusty Russell d20ddb5a90 Use libsecp256k1 instead of openssl for crypto.
We still use openssl for bignums (base58) and for ripemd.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30
Rusty Russell 5a79ef9502 Import secp256k1 (schnorr version)
Imported from: git@github.com:sipa/secp256k1.git schnorr3 (0ab0b47)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30
Rusty Russell 20624c049f tx: prepare for Elements Alpha.
They sign, hash, and serialize differently.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:45 +09:30
Rusty Russell 602117e8bb Add valgrind memcheck helpers.
Otherwise valgrind tells you when you test a hash; you want to
know if you hash uninitialized memory long before that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-24 16:15:34 +09:30
Rusty Russell c91d2b5206 ccan: add local copy.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 13:29:06 +09:30
Rusty Russell a0b621689e TAGS: Improve support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 12:44:45 +09:30
Rusty Russell 4e8eda47a1 Move hacky command line utils out to test-cli subdir.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 12:35:42 +09:30
Rusty Russell 442f321585 Move protobuf<->bitcoin converters out of bitcoin/
They're lightning-specific.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 12:35:42 +09:30
Rusty Russell 612d713470 Move bitcoin stuff into bitcoin subdir.
It's not very interesting if you're looking for LN code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 12:35:42 +09:30
Rusty Russell 2d714f5ad4 create-commit-tx: create a commit tx.
Required for unilateral close.  Also lets us test stealing funds
from a revoked transaction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-12 12:35:26 +09:30
Rusty Russell ed3f0115d6 protocol: fix horribly thinko, keep own secrets.
I had each side using the other side's hash secret.  That's a very
dumb idea, since it means you can steal from a unilateral close!

A's secret applies to A's commit transaction: it needs the
secret and B's final signature to steal funds, and that should
never happen (since A doesn't have the B's final signature, and
once A has given B the secret, they never broadcast the commit tx).

This makes the update a 4 step dance, since you need the new
revocation hash to make the other side's TX to sign.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-10 21:39:45 +09:30
Rusty Russell 3fef1584e5 update-channel-complete: final step in channel update.
(note: I didn't bother writing the code to check the sig on this).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-09 14:13:27 +09:30
Rusty Russell 3957f1e1c1 update-channel-accept: accept the channel update.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-09 14:13:27 +09:30