Rusty Russell
cb0cc80984
patch remove-timeout.patch
2016-03-15 17:07:12 +10:30
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>
2016-03-08 10:42:15 +10:30
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>
2016-03-08 10:41:15 +10:30
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>
2016-03-08 10:39:15 +10:30
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>
2016-03-08 10:38:15 +10:30
Rusty Russell
5ac1d5df00
state: include daemon/peer (only if !TEST_COVERAGE).
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:49 +10:30
Rusty Russell
65cc6bbd50
pkt_err: make it variadic.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:47 +10:30
Rusty Russell
144ab3bef4
state: make tx arguments const.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:47 +10:30
Rusty Russell
2b3d5b4049
state: remove all traces of struct state_effect.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:47 +10:30
Rusty Russell
1a20e8094f
state: return tx to be queued directly.
...
Instead of effect->broadcast_tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
e984df486d
state: return Pkt to be queued directly.
...
Instead of effect->send_pkt.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
Rusty Russell
9013a7d872
state: set peer->state directly.
...
Instead of new_state effect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
Rusty Russell
03268014b4
state: use PEER_BUSY when doing a command.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +10:30
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>
2016-01-22 06:41:46 +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
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>
2016-01-22 06:41:45 +10:30
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>
2016-01-22 06:41:45 +10:30
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>
2016-01-22 06:41:45 +10:30
Rusty Russell
4d22b4e3eb
pkt_open: use flag to indicate whether packet will offer anchor.
...
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
Anthony Towns
cadaa348e3
test_onion.py: drop repeated sha calculation
2015-10-07 13:22:44 +10:00
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>
2015-10-07 13:08:04 +10:30
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>
2015-10-07 12:34:45 +10:30
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>
2015-10-07 12:05:14 +10:30
Anthony Towns
626be23180
test_onion.py: control generate/decode from command line
2015-10-06 23:49:52 +10:00
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.
2015-10-06 23:49:52 +10:00
Anthony Towns
9ffac49c6f
onion_key: allowing both odd and even pubkeys
...
output compressed public keys; accept compressed pubkey in test_onion
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
7c36a3e058
test_onion: get rid of dummy crypto options.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:31 +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
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>
2015-10-06 12:03:03 +10:30
Rusty Russell
8e9944bc37
test: add .gitignore
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:00:26 +10:30
Rusty Russell
f693060068
test_onion: fix random padding.
...
Randomness is now at start; thanks valgrind!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:00:12 +10:30
Anthony Towns
8b0635f7d3
test_onion.py: make it possible to build an onion
...
switched from pyelliptic to hmac/binascii/cryptography for standard
functions
use our own ECDH implementation to better match the one from secp256k1
finally, add function to create an encrypted onion
2015-10-06 00:44:03 +10:00
Anthony Towns
bb26fc3026
test_onion.py: drop unused part of message secrets
2015-10-05 17:44:49 +10:00
Anthony Towns
53e13e69c9
test_onion.py: drop separate padding method
2015-10-04 15:21:06 +10:00