Commit Graph

5422 Commits

Author SHA1 Message Date
Rusty Russell 42bf766d64 state: hand tx explicitly to bitcoin_watch / bitcoin_watch_delayed
Neater than assuming it's effect->broadcast.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell c19839816e test/test_state_coverage: --dump-states
Simple code to dump the state transitions into text form.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell d88f96de17 test/test_state_coverage: speed up dot diagram generation.
We don't need a full test for this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 29f22c165d state: handle simultaneous close.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 066bf1f4e5 test/test_state_coverage: Check for deadlock.
We should always have a packet in flight unless we're in the two
waiting-for-anchor-to-mature states, or at the top of the main loop.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 642c3e36e3 test/test_state_coverage: Check that it terminates.
The state machine is infinite, but if we eliminate the normal inner
state loop, and a couple of other unusual cases where inputs can
repeat, we should be able to traverse it all.

This is slower than simply stopping when we hit a repeated state
though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +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 11f33ad12f test/test_state_coverage: test the case where we decline an HTLC.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 8308e31d6c test/test_state_coverage: ensure we produce all output packets.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell f51e9c81bf test/test_state_coverage: make sure we test all inputs.
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 847ef21c07 state: Core state machine for lightning.
It's written in a repetitive and stylized form, for easier testing.

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 1fca363b31 state_types: types for state machine.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 1b2de5c830 CCAN: add cdump.
Used to print enums.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 3b0aca81f5 CCAN: update.
Trivial updae.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell f0cab4e74b gather_updates: fix rebase error.
Didn't update amount field in d00eeded9f.
Didn't compile test either :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:50:24 +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 02a563ba82 protocol: renumber.
Use lower numbers and clean up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:02:54 +09:30
Rusty Russell fefe2deea2 protocol: add a third leg to the close operation.
This gives us a neat way to know the other end has received our sig.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:02:52 +09:30
Rusty Russell d00eeded9f protocol: split message update_remove_htlc into update_timedout_htlc and update_routefail_htlc, remove update_remove_htlc_delay.
For the moment, there's no way to remove an in-progress HTLC before
it's timed out.  The other side can remove it with a routefail, but
you can't push for it to be removed.

We may add that later, but by definition it's only a polited request, and
normally we should rely on timeouts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:02:49 +09:30
Rusty Russell 807ac38308 protocol: add decline response for HTLC.
We don't have to accept an HTLC they offer; we might not be able to
route it, or it might offer insufficient payment.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:02:46 +09:30
Rusty Russell 5bc22f0368 protocol: increase HTLC precision to 1/1000 satoshi.
This gets truncated for on-chain transactions (thus, rounding may
contribute to fees).

This also means we currently have an upper bound of 0.04 BTC per HTLC;
this can be increased later if required.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:00:47 +09:30
Rusty Russell 58a62e782d bitcoin/script: don't pass value for HTLC script.
We don't need it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 14:56:01 +09:30
Rusty Russell 186736050f test-cli: fix alpha case.
The output of grep confuses the scripts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 14:41:55 +09:30
Rusty Russell bc056fbc4d doc/deployable-lightning: point out that Fig 4 is simplified.
Fixes #4

Reported-by: Pierre <pm+lists@acinq.fr>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-15 04:23:25 +09:30
Rusty Russell 71c56e0360 doc: biblopgraphy update
Thanks to Anthony Towns for digging this up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-11 10:20:47 +09:30
Rusty Russell 17471d0788 Merge pull request #3 from pm47/master
explicitely specified proto version
2015-08-20 13:09:04 +09:30
pm47 d97c68717b explicitely specified proto version 2015-08-19 12:41:18 +02:00
Rusty Russell 785b061034 Merge branch 'pm47-master' 2015-08-19 11:32:39 +09:30
pm47 a97d390128 fixed typos in pdf 2015-08-18 12:03:28 +02:00
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 6883d28f6d doc: move dual anchor with escapes to Appendix B.
Draft 0.2; we use a single-sided anchor now, for simplicity.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 20:43:43 +09:30
Rusty Russell 3311580c62 scripts/test.sh: fix bitcoin case.
Now we use locktime, bitcoin needs delay too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:02:50 +09:30
Rusty Russell 0b33da08c1 scripts: auto-detect alpha vs bitcoin
A bit hacky, but saves editing two places.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:02:43 +09:30
Rusty Russell 6cea21750d HOWTO-USE.md: Just refer to test scripts.
This has fallen behind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:01:34 +09:30
Rusty Russell 3b214479ae test-cli/scripts/test.sh: basic HTLC spending test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 16:20:52 +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 bafc93886f test-cli/scripts/test.sh: basic HTLC creation test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:15:05 +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 7ed0b461aa commit_tx: add HTLCs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:35 +09:30
Rusty Russell 106c447d17 gather_updates: handle HTLC updates.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:35 +09:30
Rusty Russell 769f9f1cc5 gather_updates: extract some update logic into update_rhash.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:29 +09:30
Rusty Russell f0df2b7930 channel_state: add htlcs array.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell a09c0a9fa7 funding: take into account HTLC add/remove.
Enhance funding_delta() to have an HTLC delta as well as an A->B delta.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 88ca0c91d9 doc: document HTLC 2drop optimization.
We can save an opcode in both HTLC send and receive scripts by using
OP_2DROP instead of OP_DROP twice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 08ae4a687d script: HTLC support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30