Rusty Russell
388dfc355e
test/test_protocol: add fee support.
We simply record how many fee changes there are, rather than supporting
a particular level.
Fees are tricky: it's a noop to apply them when incoming, but we apply them
when they've been acked. Unlike HTLC modifications, which are symmetric,
fee updates only apply when returning to the originating node.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
056c219bc1
test/test_protocol: add checksync command to assert nodes are in sync.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
7f90d183da
test/test_protocol: simulator for the updated wire-protocol BOLT.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
cb0cc80984
patch remove-timeout.patch
9 years ago
Rusty Russell
983000428f
daemon: rename CMD_SEND_HTLC_UPDATE to CMD_SEND_HTLC_ADD
There are other updates than just adding an HTLC; make this explicit.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
4f67b59c26
protocol: rename routefail to fail.
It's a generic "I couldn't complete this" failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
40361e3dd8
state: explicit callback to check pkt_open_complete.
For now, this always succeeds, but include the hook for completeness.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
a2f4000d22
state: cleanup after anchor has been transmitted.
If something goes wrong after we've broadcast the anchor tx, we need to use
the commit tx to spend it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
5ac1d5df00
state: include daemon/peer (only if !TEST_COVERAGE).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
65cc6bbd50
pkt_err: make it variadic.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
79e1c9bb62
state: make bitcoin_commit() take a non-const peer.
We have to sign the commit at this stage, so easiest if peer isn't const
so we can sign it in-place.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
6a7a046f60
state: add peer_unwatch_close_timeout() call.
This tell us to disarm the INPUT_CLOSE_COMPLETE_TIMEOUT: either we hit
an error and are going to unilateral close, or we received their signature
successfully.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
144ab3bef4
state: make tx arguments const.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
ebf2bc57d8
state: add async anchor creation.
Actually generating the anchor transaction in my implementation
requires interaction with bitcoind, which we want to be async. So add
a callback and a new state to wait for it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
0db3c03ed1
state: fix BITCOIN_HTLC_TOTHEM_SPENT idata.
We use both union fields idata->btc and idata->htlc, which is clearly
wrong. Have peer_tx_revealed_r_value return the HTLC it's talking
about.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
2b3d5b4049
state: remove all traces of struct state_effect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
63ea6bfd7a
state: add callbacks for adding/removing watches.
This lets us eliminate struct state_effect altogether (the next patch
removes the now-unused arguments).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
1a20e8094f
state: return tx to be queued directly.
Instead of effect->broadcast_tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
e984df486d
state: return Pkt to be queued directly.
Instead of effect->send_pkt.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
7383da5f87
state: remove update_theirsig effect.
They get this from accept_pkt_update_accept() or accept_pkt_update_signature().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
63cb0667f6
state: use callbacks for htlc management.
We only have one htlc in flight at a time, but sometimes it changes:
particularly when we are lowpriority and a highpriority request comes
in. Handle this using a set of callbacks for htlc handling.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
f48adb097e
state: use peer_unexpected_pkt() for an unexpected packet.
Instead of effect->in_error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
4d9041e62a
state: fix case where we replied to an error with an error.
Found by fixing bogus test in test_state_coverage.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
9013a7d872
state: set peer->state directly.
Instead of new_state effect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
4c9a9f8982
state: return status of current command.
We temporarily move effect to the end of the arg list: we'll get rid
of it eventually.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
03268014b4
state: use PEER_BUSY when doing a command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
14ede84d87
state: set peercond in peer directly.
Instead of stop_packets or stop_commands effects.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
50a4b14a9a
test/test_state_coverage.c: remove deferred packet handling.
We no longer defer packets.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
3ab4ba1e6f
state: add _THEYCOMPLETED states to reflect receiving PKT_OPEN_COMPLETE
This is cleaner than deferring the packet receive and asking for it later.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
fd370075f2
state: use STATE_INIT and separate inputs to decide on anchor.
This is conceptually cleaner, especially since it means we're running
a command until we're set up (which prevents other commands, so no
special case needed).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
caa27f1d93
names.h/names.c: wrappers to get name for states/inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
15c5fca876
state: take struct peer instead of struct state_data.
Just a name change for the test code, but this is what we'll be using
for the daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
2c356fde55
state: remove unnecessary set_errpkt() helper.
This was needed when idata->pkt wasn't a tal pointer, for testing,
but now it always is anyway.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
85f4a7cf14
state: simplify effect.
Make it a linked list of effects, rather than one big union.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
4d22b4e3eb
pkt_open: use flag to indicate whether packet will offer anchor.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
a38d0c985e
Makefile: more fascist warnings.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Anthony Towns
cadaa348e3
test_onion.py: drop repeated sha calculation
9 years ago
Rusty Russell
beb702054b
test_onion: minor protocol change; use single SHA to create both IVs.
Suggested-by: Anthony Towns <aj@erisian.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
0c4eb06e26
test_onion: remove gratuitous dynamic alloc, cleanup on exit.
We skipped freeing the context in the too-many-hops case.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
064cf6cc39
test/onion_key: code cleanup.
Use ccan/opt, make arguments bool, remove commented-out code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Anthony Towns
626be23180
test_onion.py: control generate/decode from command line
9 years ago
Anthony Towns
beafbe1c19
test_onion.c: generate message predictably
Generate sample encrypted payload based on actual pubkey, not
libsecp256k1's internal representation of the pubkey.
9 years ago
Anthony Towns
9ffac49c6f
onion_key: allowing both odd and even pubkeys
output compressed public keys; accept compressed pubkey in test_onion
9 years ago
Anthony Towns
2042e1cdb7
onion_key: generate multiple keys at once
9 years ago
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>
9 years ago
Rusty Russell
7c36a3e058
test_onion: get rid of dummy crypto options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
32a08ce6c5
test/onion_key: helper to generate deterministic key pairs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
9aa8907e38
test_onion: Rename struct pubkey to struct onion_pubkey.
And move to onion_key.h for next patch.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
8e9944bc37
test: add .gitignore
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
f693060068
test_onion: fix random padding.
Randomness is now at start; thanks valgrind!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago