core-lightning/lightningd
Rusty Russell 50f5eb34b4 openingd: take peer before we're opening, wait for explicit funding msg.
Prior to this, lightningd would hand uninteresting peers back to connectd,
which would then return it to lightningd if it sent a non-gossip msg,
or if lightningd asked it to release the peer.

Now connectd hands the peer to lightningd once we've done the init
handshake, which hands it off to openingd.

This is a deep structural change, so we do the minimum here and cleanup
in the following patches.

Lightningd:
1. Remove peer_nongossip handling from connect_control and peer_control.
2. Remove list of outstanding fundchannel command; it was only needed to
   find the race between us asking connectd to release the peer and it
   reconnecting.
3. We can no longer tell if the remote end has started trying to fund a
   channel (until it has succeeded): it's very transitory anyway so not
   worth fixing.
4. We now always have a struct peer, and allocate an uncommitted_channel
   for it, though it may never be used if neither end funds a channel.
5. We start funding on messages for openingd: we can get a funder_reply
   or a fundee, or an error in response to our request to fund a channel.
   so we handle all of them.
6. A new peer_start_openingd() is called after connectd hands us a peer.
7. json_fund_channel just looks through local peers; there are none
   hidden in connectd any more.
8. We sometimes start a new openingd just to send an error message.

Openingd:
1. We always have information we need to accept them funding a channel (in
   the init message).
2. We have to listen for three fds: peer, gossip and master, so we opencode
   the poll.
3. We have an explicit message to start trying to fund a channel.
4. We can be told to send a message in our init message.

Testing:
1. We don't handle some things gracefully yet, so two tests are disabled.
2. 'hand_back_peer .*: now local again' from connectd is no longer a message,
   openingd says 'Handed peer, entering loop' once its managing it.
3. peer['state'] used to be set to 'GOSSIPING' (otherwise this field doesn't
   exist; 'state' is now per-channel.  It doesn't exist at all now.
4. Some tests now need to turn on IO logging in openingd, not connectd.
5. There's a gap between connecting on one node and having connectd on
   the peer hand over the connection to openingd.  Our tests sometimes
   checked getpeers() on the peer, and didn't see anything, so line_graph
   needed updating.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-09 19:44:27 +02:00
..
test fundchannel: cap 'all' at 2^24-1 satoshi. 2018-07-30 11:46:41 +02:00
.gitignore handshaked: remove. 2017-10-20 18:31:32 +02:00
bitcoind.c Use snprintf(...) instead of sprintf(...) 2018-08-02 16:14:21 +09:30
bitcoind.h bitcoind: fix spurious memleak reports. 2018-06-15 11:53:47 +02:00
chaintopology.c add more detail to log messages about feerate estimates 2018-07-29 20:12:21 +02:00
chaintopology.h improves exponential smoothing of feerate estimates (#1699) 2018-07-15 18:30:43 +02:00
channel.c lightningd: centralize refcounting behaviour for peers. 2018-08-05 02:03:58 +00:00
channel.h lightningd: get basepoints from hsmd, don't ever get seed. 2018-07-24 00:40:01 +02:00
channel_control.c lightningd: note that we should send an error msg on channel open timeout. 2018-08-05 02:03:58 +00:00
channel_control.h channel_control: Forget if unconfirmed for a long time and we are fundee. 2018-05-23 14:37:32 -07:00
channel_state.h channel_states: fold all the ONCHAIND states into one. 2018-02-23 18:02:00 +01:00
closing_control.c Remove deprecated closing support from closingd. 2018-07-29 16:22:01 +02:00
closing_control.h gossipd: drain fd instead of passing around gossip index. 2018-04-26 05:47:57 +00:00
connect_control.c openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
connect_control.h gossipd: remove connectd functionality, enable connectd. 2018-07-25 02:13:52 +00:00
dev_ping.c gossipd: handle ping messages for remote peers too. 2018-07-25 02:13:52 +00:00
gossip_control.c json: json_add_hex_talarr for common case of dumping a tal object in hex. 2018-07-30 11:31:17 +02:00
gossip_control.h connectd: wean off gossip_wire message types, use our own. 2018-07-25 02:13:52 +00:00
gossip_msg.c lightningd: display all addresses in listnodes. 2018-08-06 19:33:46 +02:00
gossip_msg.h gossipd: add flag for locally disabling channel. 2018-07-27 14:12:00 +02:00
hsm_control.c lightningd: get basepoints from hsmd, don't ever get seed. 2018-07-24 00:40:01 +02:00
hsm_control.h hsmd: fix missing status messages. 2018-07-17 12:32:00 +02:00
htlc_end.c Remove unused parameter ptr in corrupt(const void *ptr, ...) 2018-02-22 10:46:30 +01:00
htlc_end.h htlc: keep channel pointer, not peer pointer. 2018-02-14 11:31:58 +01:00
invoice.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
invoice.h invoices: Extensive reorganization of invoice system. 2018-01-16 13:03:54 +01:00
json.c json-rpc: Add description to listpayments and similar 2018-07-30 03:04:45 +00:00
json.h gossipd/lightningd: use wireaddr_internal. 2018-05-07 22:37:28 +02:00
jsonrpc.c Added json_tok_sha256 (#1779) 2018-07-31 04:11:01 +00:00
jsonrpc.h fundchannel: cap 'all' at 2^24-1 satoshi. 2018-07-30 11:46:41 +02:00
jsonrpc_errors.h renamed error code 2018-07-29 16:27:38 +02:00
lightningd.c openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
lightningd.h openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
log.c Use snprintf(...) instead of sprintf(...) 2018-08-02 16:14:21 +09:30
log.h common/daemon: common routines for all daemons. 2018-04-03 14:03:28 +02:00
log_status.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
log_status.h status: add multiple levels of logging. 2018-02-07 00:46:49 +00:00
Makefile gossipd: remove connectd functionality, enable connectd. 2018-07-25 02:13:52 +00:00
memdump.c Use snprintf(...) instead of sprintf(...) 2018-08-02 16:14:21 +09:30
onchain_control.c onchaind: use the HSM to get the per-commitment-point. 2018-07-24 00:40:01 +02:00
onchain_control.h onchaind: Replay stored channeltxs to restore onchaind state 2018-04-25 14:33:38 +02:00
opening_control.c openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
opening_control.h openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
options.c lightningd: show selected network defaults in usage 2018-08-01 13:08:02 +09:30
options.h hsmd: drop newdir logic. 2018-05-05 17:55:10 +02:00
param.c Added json_tok_sha256 (#1779) 2018-07-31 04:11:01 +00:00
param.h lightningd: fix crash on rpc.invoice with clang 2018-07-20 16:51:40 +02:00
pay.c Added json_tok_sha256 (#1779) 2018-07-31 04:11:01 +00:00
pay.h pay: Pass description to send_payment 2018-07-30 03:04:45 +00:00
payalgo.c json: json_add_hex_talarr for common case of dumping a tal object in hex. 2018-07-30 11:31:17 +02:00
payalgo.h payalgo: New file for pay command. 2018-02-16 13:08:29 +01:00
peer_control.c openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
peer_control.h openingd: take peer before we're opening, wait for explicit funding msg. 2018-08-09 19:44:27 +02:00
peer_htlcs.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
peer_htlcs.h channel_control: Forget if unconfirmed for a long time and we are fundee. 2018-05-23 14:37:32 -07:00
subd.c lightningd: don't dump core on subdaemon failure. 2018-08-05 02:03:58 +00:00
subd.h hsmd: fix missing status messages. 2018-07-17 12:32:00 +02:00
watch.c exchanged code containing goto with a do while loop (#1758) 2018-07-26 23:17:45 +02:00
watch.h topo: Remove in-memory txs from the block struct 2018-04-13 00:04:37 +02:00