Rusty Russell
04db39558d
htlc_tx: use keyset abstraction.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
4bfaaef408
keyset: abstraction over what keys we need for a specific commitment.
...
onchaind will need to do similar logic to channeld, so this allows them
to share much more code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
edd27d21b5
lightningd: save last htlc sigs.
...
This belongs in the db, but until then...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
b6d7ad0614
lightningd: store the htlc stubs.
...
These belong in the database, but for now just keep an array.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
893335244d
openingd: supply initial tx as well as signature.
...
And store in peer->last_tx/peer->last_sig like all other places,
that way we broadcast it if we need to.
Note: the removal of tmpctx in funder_channel() is needed because we
use txs[0], which was allocated off tmpctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
80e28707a3
channeld: send commit tx and signature to master.
...
This also means we can simply drop it to chain on error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
c389215a35
closingd: send the tx to master as we negotiate.
...
We can derive fees from this, and also broadcast at any time without
having to reconstruct it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
dbfac68c3f
lightningd: keep last valid tx, and its signature.
...
This avoids us having to reconstruct it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
8e0c19c76a
lightningd: add dev-fail command to inject permenant failure.
...
A couple of double-free bugs founnd doing this, too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
524e56cf56
dev_disconnect: support '*N' syntax for disconnecting on the N'th occurance.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
99581bd709
dev_disconnect: support 'permfail' line to permanently fail peer.
...
The master daemon checks for this after a subdaemon dies.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
f5f8ca5352
onchain/onchain_wire: routines to marshal/unmarshal htlc stubs.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
f765e0e846
bip32: marshal/unmarshal routines.
...
Neater than using a u8 array as we do now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
bcc9ed9aa6
lightningd/htlc_wire: marshal/unmashal bitcoin tx.
...
We want to keep the last valid tx, and its signature, for broadcast.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
a4f290daba
htlc_wire: marshal/unmarshal shachain object.
...
We want to hand it to onchaind.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
217df2d2e8
channeld: fix shutdown when we have to complete HTLCs.
...
We need to check if we exit after sending a revoke_and_ack, otherwise
channeld ends up getting the closing_signed packet.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
f5624af965
lightningd: fix error packet we send due to permanent error.
...
tal_strdup() doesn't set tal_count(), so we end up sending an ERROR
packet with an empty message. Wrap this and get it right.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
ce24731da9
lightningd: use internal_error rather than freeing peer.
...
Should never free peer directly: we need to log error, etc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Rusty Russell
709991fed1
subd: fix case where we replycb calls peer_internal_error().
...
It frees the sd, destroy_subd() frees sd->conn, then we call io_close(conn).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-20 13:06:41 +09:30
Christian Decker
6dbd99ddc6
gossip: Fix a race condition between release_peer and fail_peer
...
There was a race condition that would cause an assertion to segfault
if a call to release_peer was interleaved with a fail_peer. The
release_peer was making the peer non-local, which was then causing the
assertion in fail_peer to fail. Now we just have 3 cases: not found,
local, and non-local.
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-17 10:31:55 +09:30
Christian Decker
cc5af13e05
wallet: Implement channel_config persistence
2017-08-10 12:34:58 +09:30
Christian Decker
ca00ec0bb8
htlc: Include htlc_wire.h in peer_htlcs.h to avoid forward decl
2017-08-10 12:34:58 +09:30
Christian Decker
85d2256898
wallet: Use persistent shachain for remote secrets
2017-08-10 12:34:58 +09:30
Christian Decker
28cc92cd15
gossip: Use bit 3 (mask 0x08) to signal initial routing sync
...
After quite some back and forth we seem to finally agree on the bit
3 (mask 0x08) to signal optional initial_routing_sync.
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-08-09 10:01:33 +09:30
Rusty Russell
40895e4550
Update to match spec: "BOLT7: Reorder feature bitmaps in order to allow future changes"
...
aka. a257554456cda98afd1532c302c0e5e84de0455e
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-03 14:26:41 +02:00
Rusty Russell
2b7c091e70
closing: update to match proposal to restart negotiation on reconnect.
...
This simplifies significantly, as we don't need to remember what we offered.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-02 11:45:30 +09:30
Christian Decker
35847206b2
fix: Allow pings while waiting for the channel to lock
...
This was causing failures on testnet where confirmations are not
immediate.
Reported-by: Fabrice Drouin @sstone
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-07-22 09:52:14 +09:30
Christian Decker
2bf92c9063
peer: Check localfeatures and globalfeatures against what we support ( #195 )
...
We support a number of features already, so failing connections
whenever we see an even bit set is not a good idea. This turned out to
kill our connections to eclair.
Also, the spec says that the LSB / bit 0 is to be counted as index 0, and
therefore even. So we need to check the lower of each 2-bit-tuple not
the higher one.
2017-07-16 10:38:26 +09:30
Christian Decker
7dc693963d
script: Consolidate scripts to use pubkey_to_hash160
2017-07-15 10:19:33 +09:30
sstone
f371b6df20
sphinx: fix payload amount encoding
...
it was changed to 64 bits
2017-07-14 19:27:33 +02:00
Christian Decker
83c8c3fc52
opening: Use the correct chainparams to open a channel
...
We were using the bitcoin genesis blockhash for all networks, which is
not correct, and would result in the open being aborted when talking
to other implementations.
Reported-by: @sstone and @pm47
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-07-12 11:30:23 +09:30
Christian Decker
fbc2b65a3d
opening: Pass network_index through to openingd
...
This is needed in order to open channels with the correct
genesis_blockhash.
Reported-By: @sstone
2017-07-12 11:30:23 +09:30
Christian Decker
843e21826a
opts: Remove --regtest flag and pass chainparams to bitcoind
2017-07-12 11:30:23 +09:30
Christian Decker
cf16b5faea
options: Add option to set the network
2017-07-12 11:30:23 +09:30
Christian Decker
9370a3cdd2
opening: Fix switched parameters for towire_accept_channel
...
Turns out we were serializing two parameters in the wrong order.
2017-07-12 11:00:26 +09:30
Christian Decker
1a1e29a4bc
gossip: Re-initiate the broadcast timer upon reconnect
...
We weren't registering reconnecting peers for broadcasts. Just
starting a timer is enough. Also added an integration test to check
that the gossip sync is being resumed.
2017-07-12 11:00:26 +09:30
Rusty Russell
03be40ea8b
lightningd: don't reset balance when we reconnect!
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
8b71ea924a
lightningd: don't crash when simply using closingd just for retransmission.
...
test_closing_negotiation_reconnect (__main__.LightningDTests) ... peer state CLOSINGD_COMPLETE should be CLOSINGD_SIGEXCHANGE
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
a87d50acc9
Makefile: clean daemons on clean.
...
Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
7d3e074863
Misc feedback minor fixes.
...
Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
87232ec25c
lightningd: new peer state CLOSINGD_COMPLETE.
...
This is a transitional state, while we're waiting to see the
closing tx onchain (which is To Be Implemented).
The simplest way to do re-transmission is to re-use closingd, and just
disallow any updates.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
c1f21b9fce
lightningd/peer_control.c: rename peer->balance.
...
I made the mistake of thinking it was a [NUM_SIDES] array, but
it's actually our balance, and it's in millisatoshi. Rename
for clarity.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
4223a91842
lightningd: update daemon list.
...
This is used to check that versions are correct on startup.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
0c5e238a48
lightningd: handle reconnect during shutdown and closing.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
0c07856ae4
lightningd/peer_control.c: remove unnecessary reconnected field.
...
It can be on the stack.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
a827d2b2bb
lightningd: add in support for closingd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
e5a8a7502c
lightningd/closing: subdaemon for closing negotiation.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
6fa90c926a
channeld: exit after shutdown when no more HTLCs.
...
Ready for the introduction of closingd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
80886cda8a
daemon_conn: fix daemon_conn_sync_flush.
...
We need to set fd to blocking before trying to sync write. Use
io_fd_block() elsewhere, too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30
Rusty Russell
94a33a7d15
channeld: use an enum side not a bool for funder/
...
This predated our handling of enums.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-07-12 10:21:16 +09:30