diff --git a/Makefile b/Makefile index 39b600335f0f..3d11b3299ba0 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../bolts/ -DEFAULT_BOLTVERSION := 03468e17563650fb9bfe58b2da4d1e5d28e92009 +DEFAULT_BOLTVERSION := bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730 # Can be overridden on cmdline. BOLTVERSION := $(DEFAULT_BOLTVERSION) diff --git a/channeld/channeld.c b/channeld/channeld.c index 15aabc5b984f..9777959a6d9b 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1,4 +1,4 @@ -/* Main channel operation daemon: runs from funding_locked to shutdown_complete. +/* Main channel operation daemon: runs from channel_ready to shutdown_complete. * * We're fairly synchronous: our main loop looks for master or * peer requests and services them synchronously. @@ -52,7 +52,7 @@ struct peer { struct per_peer_state *pps; - bool funding_locked[NUM_SIDES]; + bool channel_ready[NUM_SIDES]; u64 next_index[NUM_SIDES]; /* Features peer supports. */ @@ -182,7 +182,7 @@ struct peer { /* Penalty bases for this channel / peer. */ struct penalty_base **pbases; - /* We allow a 'tx-sigs' message between reconnect + funding_locked */ + /* We allow a 'tx-sigs' message between reconnect + channel_ready */ bool tx_sigs_allowed; /* Have we announced the real scid with a @@ -204,7 +204,7 @@ static void start_commit_timer(struct peer *peer); static void billboard_update(const struct peer *peer) { - const char *update = billboard_message(tmpctx, peer->funding_locked, + const char *update = billboard_message(tmpctx, peer->channel_ready, peer->have_sigs, peer->shutdown_sent, peer->depth_togo, @@ -539,7 +539,7 @@ static void channel_announcement_negotiate(struct peer *peer) return; /* Can't do anything until funding is locked. */ - if (!peer->funding_locked[LOCAL] || !peer->funding_locked[REMOTE]) + if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE]) return; if (!peer->channel_local_active) { @@ -560,7 +560,7 @@ static void channel_announcement_negotiate(struct peer *peer) * A node: * - if the `open_channel` message has the `announce_channel` bit set AND a `shutdown` message has not been sent: * - MUST send the `announcement_signatures` message. - * - MUST NOT send `announcement_signatures` messages until `funding_locked` + * - MUST NOT send `announcement_signatures` messages until `channel_ready` * has been sent and received AND the funding transaction has at least six confirmations. * - otherwise: * - MUST NOT send the `announcement_signatures` message. @@ -570,7 +570,7 @@ static void channel_announcement_negotiate(struct peer *peer) /* BOLT #7: * - * - MUST NOT send `announcement_signatures` messages until `funding_locked` + * - MUST NOT send `announcement_signatures` messages until `channel_ready` * has been sent and received AND the funding transaction has at least six confirmations. */ if (peer->announce_depth_reached && !peer->have_sigs[LOCAL]) { @@ -602,18 +602,18 @@ static void channel_announcement_negotiate(struct peer *peer) } } -static void handle_peer_funding_locked(struct peer *peer, const u8 *msg) +static void handle_peer_channel_ready(struct peer *peer, const u8 *msg) { struct channel_id chanid; - struct tlv_funding_locked_tlvs *tlvs; + struct tlv_channel_ready_tlvs *tlvs; /* BOLT #2: * * A node: *... * - upon reconnection: - * - MUST ignore any redundant `funding_locked` it receives. + * - MUST ignore any redundant `channel_ready` it receives. */ - if (peer->funding_locked[REMOTE]) + if (peer->channel_ready[REMOTE]) return; /* Too late, we're shutting down! */ @@ -621,10 +621,10 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg) return; peer->old_remote_per_commit = peer->remote_per_commit; - if (!fromwire_funding_locked(msg, msg, &chanid, + if (!fromwire_channel_ready(msg, msg, &chanid, &peer->remote_per_commit, &tlvs)) peer_failed_warn(peer->pps, &peer->channel_id, - "Bad funding_locked %s", tal_hex(msg, msg)); + "Bad channel_ready %s", tal_hex(msg, msg)); if (!channel_id_eq(&chanid, &peer->channel_id)) peer_failed_err(peer->pps, &chanid, @@ -634,17 +634,17 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg) &peer->channel_id)); peer->tx_sigs_allowed = false; - peer->funding_locked[REMOTE] = true; - if (tlvs->alias != NULL) { + peer->channel_ready[REMOTE] = true; + if (tlvs->short_channel_id != NULL) { status_debug( "Peer told us that they'll use alias=%s for this channel", type_to_string(tmpctx, struct short_channel_id, - tlvs->alias)); - peer->short_channel_ids[REMOTE] = *tlvs->alias; + tlvs->short_channel_id)); + peer->short_channel_ids[REMOTE] = *tlvs->short_channel_id; } wire_sync_write(MASTER_FD, - take(towire_channeld_got_funding_locked( - NULL, &peer->remote_per_commit, tlvs->alias))); + take(towire_channeld_got_channel_ready( + NULL, &peer->remote_per_commit, tlvs->short_channel_id))); channel_announcement_negotiate(peer); billboard_update(peer); @@ -2119,8 +2119,8 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg) struct bitcoin_txid txid; /* In a rare case, a v2 peer may re-send a tx_sigs message. - * This happens when they've/we've exchanged funding_locked, - * but they did not receive our funding_locked. */ + * This happens when they've/we've exchanged channel_ready, + * but they did not receive our channel_ready. */ if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid, cast_const3(struct witness_stack ***, &ws))) peer_failed_warn(peer->pps, &peer->channel_id, @@ -2212,9 +2212,9 @@ static void peer_in(struct peer *peer, const u8 *msg) if (handle_peer_error(peer->pps, &peer->channel_id, msg)) return; - /* Must get funding_locked before almost anything. */ - if (!peer->funding_locked[REMOTE]) { - if (type != WIRE_FUNDING_LOCKED + /* Must get channel_ready before almost anything. */ + if (!peer->channel_ready[REMOTE]) { + if (type != WIRE_CHANNEL_READY && type != WIRE_SHUTDOWN /* We expect these for v2 !! */ && type != WIRE_TX_SIGNATURES @@ -2228,8 +2228,8 @@ static void peer_in(struct peer *peer, const u8 *msg) } switch (type) { - case WIRE_FUNDING_LOCKED: - handle_peer_funding_locked(peer, msg); + case WIRE_CHANNEL_READY: + handle_peer_channel_ready(peer, msg); return; case WIRE_ANNOUNCEMENT_SIGNATURES: handle_peer_announcement_signatures(peer, msg); @@ -2664,7 +2664,7 @@ static void check_current_dataloss_fields(struct peer *peer, status_debug("option_data_loss_protect: fields are correct"); } -/* Older LND sometimes sends funding_locked before reestablish! */ +/* Older LND sometimes sends channel_ready before reestablish! */ /* ... or announcement_signatures. Sigh, let's handle whatever they send. */ static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg) { @@ -2941,19 +2941,21 @@ static void peer_reconnect(struct peer *peer, * * - if `next_commitment_number` is 1 in both the * `channel_reestablish` it sent and received: - * - MUST retransmit `funding_locked`. + * - MUST retransmit `channel_ready`. * - otherwise: - * - MUST NOT retransmit `funding_locked`. + * - MUST NOT retransmit `channel_ready`, but MAY send + * `channel_ready` with a different `short_channel_id` + * `alias` field. */ - if (peer->funding_locked[LOCAL] + if (peer->channel_ready[LOCAL] && peer->next_index[LOCAL] == 1 && next_commitment_number == 1) { - struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx); + struct tlv_channel_ready_tlvs *tlvs = tlv_channel_ready_tlvs_new(tmpctx); status_debug("Retransmitting funding_locked for channel %s", type_to_string(tmpctx, struct channel_id, &peer->channel_id)); /* Contains per commit point #1, for first post-opening commit */ - msg = towire_funding_locked(NULL, + msg = towire_channel_ready(NULL, &peer->channel_id, &peer->next_local_per_commit, tlvs); peer_write(peer->pps, take(msg)); @@ -3229,7 +3231,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) { u32 depth; struct short_channel_id *scid, *alias_local; - struct tlv_funding_locked_tlvs *tlvs; + struct tlv_channel_ready_tlvs *tlvs; struct pubkey point; if (!fromwire_channeld_funding_depth(tmpctx, @@ -3258,25 +3260,25 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) else if (alias_local) peer->short_channel_ids[LOCAL] = *alias_local; - if (!peer->funding_locked[LOCAL]) { - status_debug("funding_locked: sending commit index" + if (!peer->channel_ready[LOCAL]) { + status_debug("channel_ready: sending commit index" " %"PRIu64": %s", peer->next_index[LOCAL], type_to_string(tmpctx, struct pubkey, &peer->next_local_per_commit)); - tlvs = tlv_funding_locked_tlvs_new(tmpctx); - tlvs->alias = alias_local; + tlvs = tlv_channel_ready_tlvs_new(tmpctx); + tlvs->short_channel_id = alias_local; /* Need to retrieve the first point again, even if we - * moved on, as funding_locked explicitly includes the + * moved on, as channel_ready explicitly includes the * first one. */ get_per_commitment_point(1, &point, NULL); - msg = towire_funding_locked(NULL, &peer->channel_id, + msg = towire_channel_ready(NULL, &peer->channel_id, &point, tlvs); peer_write(peer->pps, take(msg)); - peer->funding_locked[LOCAL] = true; + peer->channel_ready[LOCAL] = true; } peer->announce_depth_reached = (depth >= ANNOUNCE_MIN_DEPTH); @@ -3310,7 +3312,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) struct amount_sat htlc_fee; struct pubkey *blinding; - if (!peer->funding_locked[LOCAL] || !peer->funding_locked[REMOTE]) + if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE]) status_failed(STATUS_FAIL_MASTER_IO, "funding not locked for offer_htlc"); @@ -3745,7 +3747,7 @@ static void req_in(struct peer *peer, const u8 *msg) case WIRE_CHANNELD_SENDING_COMMITSIG_REPLY: case WIRE_CHANNELD_GOT_COMMITSIG_REPLY: case WIRE_CHANNELD_GOT_REVOKE_REPLY: - case WIRE_CHANNELD_GOT_FUNDING_LOCKED: + case WIRE_CHANNELD_GOT_CHANNEL_READY: case WIRE_CHANNELD_GOT_ANNOUNCEMENT: case WIRE_CHANNELD_GOT_SHUTDOWN: case WIRE_CHANNELD_SHUTDOWN_COMPLETE: @@ -3837,8 +3839,8 @@ static void init_channel(struct peer *peer) &peer->revocations_received, &peer->htlc_id, &htlcs, - &peer->funding_locked[LOCAL], - &peer->funding_locked[REMOTE], + &peer->channel_ready[LOCAL], + &peer->channel_ready[REMOTE], &peer->short_channel_ids[LOCAL], &reconnected, &peer->send_shutdown, diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index 31d8237a2e1d..78abd73416ae 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -53,8 +53,8 @@ msgdata,channeld_init,revocations_received,u64, msgdata,channeld_init,next_htlc_id,u64, msgdata,channeld_init,num_existing_htlcs,u16, msgdata,channeld_init,htlcs,existing_htlc,num_existing_htlcs -msgdata,channeld_init,local_funding_locked,bool, -msgdata,channeld_init,remote_funding_locked,bool, +msgdata,channeld_init,local_channel_ready,bool, +msgdata,channeld_init,remote_channel_ready,bool, msgdata,channeld_init,funding_short_id,short_channel_id, msgdata,channeld_init,reestablish,bool, msgdata,channeld_init,send_shutdown,bool, @@ -117,10 +117,10 @@ msgdata,channeld_fulfill_htlc,fulfilled_htlc,fulfilled_htlc, msgtype,channeld_fail_htlc,1006 msgdata,channeld_fail_htlc,failed_htlc,failed_htlc, -# When we receive funding_locked. -msgtype,channeld_got_funding_locked,1019 -msgdata,channeld_got_funding_locked,next_per_commit_point,pubkey, -msgdata,channeld_got_funding_locked,alias,?short_channel_id, +# When we receive channel_ready. +msgtype,channeld_got_channel_ready,1019 +msgdata,channeld_got_channel_ready,next_per_commit_point,pubkey, +msgdata,channeld_got_channel_ready,alias,?short_channel_id, #include diff --git a/closingd/closingd.c b/closingd/closingd.c index 30739e0a5486..73b22ab34343 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -260,11 +260,11 @@ receive_offer(struct per_peer_state *pps, /* BOLT #2: * * - upon reconnection: - * - MUST ignore any redundant `funding_locked` it receives. + * - MUST ignore any redundant `channel_ready` it receives. */ /* This should only happen if we've made no commitments, but * we don't have to check that: it's their problem. */ - if (fromwire_peektype(msg) == WIRE_FUNDING_LOCKED) + if (fromwire_peektype(msg) == WIRE_CHANNEL_READY) msg = tal_free(msg); /* BOLT #2: * - if it has sent a previous `shutdown`: diff --git a/common/channel_type.c b/common/channel_type.c index a2b1cab37788..07c815217c40 100644 --- a/common/channel_type.c +++ b/common/channel_type.c @@ -8,7 +8,7 @@ * arbitrary combination (they represent the persistent features which * affect the channel operation). * - * The currently defined types are: + * The currently defined basic types are: * - no features (no bits set) * - `option_static_remotekey` (bit 12) * - `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12) @@ -118,8 +118,11 @@ struct channel_type *channel_type_accept(const tal_t *ctx, OPT_ZEROCONF, }; - /* The basic channel_types can have any number of the - * following optional bits. */ + /* BOLT #2: + * Each basic type has the following variations allowed: + * - `option_scid_alias` (bit 46) + * - `option_zeroconf` (bit 50) + */ static const size_t variants[] = { OPT_ZEROCONF, }; diff --git a/common/gossip_constants.h b/common/gossip_constants.h index dac2562eb9fb..3ce395eac70e 100644 --- a/common/gossip_constants.h +++ b/common/gossip_constants.h @@ -32,7 +32,7 @@ /* BOLT #7: * - * - MUST NOT send `announcement_signatures` messages until `funding_locked` + * - MUST NOT send `announcement_signatures` messages until `channel_ready` * has been sent and received AND the funding transaction has at least six * confirmations. */ diff --git a/common/gossip_store.c b/common/gossip_store.c index 086232c2953f..2f3f329a2d2e 100644 --- a/common/gossip_store.c +++ b/common/gossip_store.c @@ -69,7 +69,7 @@ static bool public_msg_type(enum peer_wire type) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_OPEN_CHANNEL2: case WIRE_ACCEPT_CHANNEL2: case WIRE_INIT_RBF: diff --git a/connectd/gossip_rcvd_filter.c b/connectd/gossip_rcvd_filter.c index 13ff0a2f7c0c..7e3c72331001 100644 --- a/connectd/gossip_rcvd_filter.c +++ b/connectd/gossip_rcvd_filter.c @@ -71,7 +71,7 @@ static bool is_msg_gossip_broadcast(const u8 *cursor) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_SHUTDOWN: case WIRE_CLOSING_SIGNED: case WIRE_UPDATE_ADD_HTLC: diff --git a/connectd/multiplex.c b/connectd/multiplex.c index ae7f7585b73d..96a32fce017e 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -361,7 +361,7 @@ static bool is_urgent(enum peer_wire type) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_OPEN_CHANNEL2: case WIRE_ACCEPT_CHANNEL2: case WIRE_INIT_RBF: diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 55321e1dbce2..8c42eec96bc7 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -529,7 +529,7 @@ static void handle_recv_gossip(struct daemon *daemon, const u8 *outermsg) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_SHUTDOWN: case WIRE_CLOSING_SIGNED: case WIRE_UPDATE_ADD_HTLC: diff --git a/lightningd/channel.c b/lightningd/channel.c index fbf1f4ba8f95..8a35558c0502 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -221,7 +221,7 @@ struct channel *new_unsaved_channel(struct peer *peer, channel->open_attempt = NULL; channel->last_htlc_sigs = NULL; - channel->remote_funding_locked = false; + channel->remote_channel_ready = false; channel->scid = NULL; channel->next_index[LOCAL] = 1; channel->next_index[REMOTE] = 1; @@ -345,7 +345,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, struct amount_sat funding_sats, struct amount_msat push, struct amount_sat our_funds, - bool remote_funding_locked, + bool remote_channel_ready, /* NULL or stolen */ struct short_channel_id *scid, struct short_channel_id *alias_local STEALS, @@ -441,7 +441,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, channel->funding_sats = funding_sats; channel->push = push; channel->our_funds = our_funds; - channel->remote_funding_locked = remote_funding_locked; + channel->remote_channel_ready = remote_channel_ready; channel->scid = tal_steal(channel, scid); channel->alias[LOCAL] = tal_steal(channel, alias_local); channel->alias[REMOTE] = tal_steal(channel, alias_remote); /* Haven't gotten one yet. */ diff --git a/lightningd/channel.h b/lightningd/channel.h index eba34ffa0836..a971b012e42f 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -138,7 +138,7 @@ struct channel { struct amount_sat our_funds; struct amount_msat push; - bool remote_funding_locked; + bool remote_channel_ready; /* Channel if locked locally. */ struct short_channel_id *scid; @@ -291,7 +291,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, struct amount_sat funding_sats, struct amount_msat push, struct amount_sat our_funds, - bool remote_funding_locked, + bool remote_channel_ready, /* NULL or stolen */ struct short_channel_id *scid STEALS, struct short_channel_id *alias_local STEALS, diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 8d2cbb24457e..5d4873d8c5ad 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -195,7 +195,7 @@ static void lockin_complete(struct channel *channel) } /* We set this once they're locked in. */ - assert(channel->remote_funding_locked); + assert(channel->remote_channel_ready); /* We might have already started shutting down */ if (channel->state != CHANNELD_AWAITING_LOCKIN) { @@ -225,41 +225,37 @@ static void lockin_complete(struct channel *channel) true); } -bool channel_on_funding_locked(struct channel *channel, - struct pubkey *next_per_commitment_point) +bool channel_on_channel_ready(struct channel *channel, + struct pubkey *next_per_commitment_point) { - if (channel->remote_funding_locked) { + if (channel->remote_channel_ready) { channel_internal_error(channel, - "channel_got_funding_locked twice"); + "channel_got_channel_ready twice"); return false; } update_per_commit_point(channel, next_per_commitment_point); - log_debug(channel->log, "Got funding_locked"); - channel->remote_funding_locked = true; + log_debug(channel->log, "Got channel_ready"); + channel->remote_channel_ready = true; return true; } -/* We were informed by channeld that it announced the channel and sent - * an update, so we can now start sending a node_announcement. The - * first step is to build the provisional announcement and ask the HSM - * to sign it. */ - -static void peer_got_funding_locked(struct channel *channel, const u8 *msg) +/* We were informed by channeld that channel is ready (reached mindepth) */ +static void peer_got_channel_ready(struct channel *channel, const u8 *msg) { struct pubkey next_per_commitment_point; struct short_channel_id *alias_remote; - if (!fromwire_channeld_got_funding_locked(tmpctx, + if (!fromwire_channeld_got_channel_ready(tmpctx, msg, &next_per_commitment_point, &alias_remote)) { channel_internal_error(channel, - "bad channel_got_funding_locked %s", + "bad channel_got_channel_ready %s", tal_hex(channel, msg)); return; } - if (!channel_on_funding_locked(channel, &next_per_commitment_point)) + if (!channel_on_channel_ready(channel, &next_per_commitment_point)) return; if (channel->alias[REMOTE] == NULL) @@ -538,8 +534,8 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds) case WIRE_CHANNELD_GOT_REVOKE: peer_got_revoke(sd->channel, msg); break; - case WIRE_CHANNELD_GOT_FUNDING_LOCKED: - peer_got_funding_locked(sd->channel, msg); + case WIRE_CHANNELD_GOT_CHANNEL_READY: + peer_got_channel_ready(sd->channel, msg); break; case WIRE_CHANNELD_GOT_ANNOUNCEMENT: peer_got_announcement(sd->channel, msg); @@ -765,7 +761,7 @@ bool peer_start_channeld(struct channel *channel, channel->next_htlc_id, htlcs, channel->scid != NULL, - channel->remote_funding_locked, + channel->remote_channel_ready, &scid, reconnected, /* Anything that indicates we are or have @@ -859,12 +855,11 @@ bool channel_tell_depth(struct lightningd *ld, take(towire_channeld_funding_depth( NULL, channel->scid, channel->alias[LOCAL], depth))); - if (channel->remote_funding_locked && - channel->state == CHANNELD_AWAITING_LOCKIN && - depth >= channel->minimum_depth) + if (channel->remote_channel_ready && + channel->state == CHANNELD_AWAITING_LOCKIN && + depth >= channel->minimum_depth) { lockin_complete(channel); - - else if (depth == 1 && channel->minimum_depth == 0) { + } else if (depth == 1 && channel->minimum_depth == 0) { /* If we have a zeroconf channel, i.e., no scid yet * but have exchange `channel_ready` messages, then we * need to fire a second time, in order to trigger the diff --git a/lightningd/channel_control.h b/lightningd/channel_control.h index 9008bed1d055..2f8b356e863d 100644 --- a/lightningd/channel_control.h +++ b/lightningd/channel_control.h @@ -30,9 +30,9 @@ void channel_notify_new_block(struct lightningd *ld, struct command_result *cancel_channel_before_broadcast(struct command *cmd, struct peer *peer); -/* Update the channel info on funding locked */ -bool channel_on_funding_locked(struct channel *channel, - struct pubkey *next_per_commitment_point); +/* Update the channel info on channel_ready */ +bool channel_on_channel_ready(struct channel *channel, + struct pubkey *next_per_commitment_point); /* Record channel open (coin movement notifications) */ void channel_record_open(struct channel *channel, u32 blockheight, bool record_push); diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index fa458bca3a35..a2f84ee61da0 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -1631,7 +1631,7 @@ static void handle_peer_tx_sigs_sent(struct subd *dualopend, &channel->peer->id, &channel->funding_sats, &channel->funding.txid, - channel->remote_funding_locked); + channel->remote_channel_ready); /* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2 * The receiving node: ... @@ -1714,7 +1714,7 @@ static void handle_peer_locked(struct subd *dualopend, const u8 *msg) /* Updates channel with the next per-commit point etc, calls * channel_internal_error on failure */ - if (!channel_on_funding_locked(channel, &remote_per_commit)) + if (!channel_on_channel_ready(channel, &remote_per_commit)) return; /* Remember that we got the lock-in */ @@ -1737,7 +1737,7 @@ static void handle_channel_locked(struct subd *dualopend, peer_fd = new_peer_fd_arr(tmpctx, fds); assert(channel->scid); - assert(channel->remote_funding_locked); + assert(channel->remote_channel_ready); /* This can happen if we missed their sigs, for some reason */ if (channel->state != DUALOPEND_AWAITING_LOCKIN) @@ -1997,7 +1997,7 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend, &channel->peer->id, &channel->funding_sats, &channel->funding.txid, - channel->remote_funding_locked); + channel->remote_channel_ready); /* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2 * The receiving node: ... @@ -3364,10 +3364,14 @@ bool peer_start_dualopend(struct peer *peer, /* BOLT #2: * * The sender: - * - SHOULD set `minimum_depth` to a number of blocks it - * considers reasonable to avoid double-spending of the - * funding transaction. + * - if `channel_type` includes `option_zeroconf`: + * - MUST set `minimum_depth` to zero. + * - otherwise: + * - SHOULD set `minimum_depth` to a number of blocks it + * considers reasonable to avoid double-spending of the + * funding transaction. */ + /* FIXME: We should override this to 0 in the openchannel2 hook of we want zeroconf*/ channel->minimum_depth = peer->ld->config.anchor_confirms; msg = towire_dualopend_init(NULL, chainparams, @@ -3470,7 +3474,7 @@ bool peer_restart_dualopend(struct peer *peer, inflight->funding_psbt, channel->opener, channel->scid != NULL, - channel->remote_funding_locked, + channel->remote_channel_ready, channel->state == CHANNELD_SHUTTING_DOWN, channel->shutdown_scriptpubkey[REMOTE] != NULL, channel->shutdown_scriptpubkey[LOCAL], diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index 4eb634cfeb81..232dc2a11dae 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -625,7 +625,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel, channel_fail_permanent(channel, reason, "Funding transaction spent"); /* If we haven't posted the open event yet, post an open */ - if (!channel->scid || !channel->remote_funding_locked) { + if (!channel->scid || !channel->remote_channel_ready) { u32 blkh; /* Blockheight will be zero if it's not in chain */ blkh = wallet_transaction_height(channel->peer->ld->wallet, diff --git a/lightningd/opening_common.c b/lightningd/opening_common.c index 778648b0a55b..5f2f848d8c83 100644 --- a/lightningd/opening_common.c +++ b/lightningd/opening_common.c @@ -55,9 +55,14 @@ new_uncommitted_channel(struct peer *peer) /* BOLT #2: * * The sender: - * - SHOULD set `minimum_depth` to a number of blocks it considers - * reasonable to avoid double-spending of the funding transaction. + * - if `channel_type` includes `option_zeroconf`: + * - MUST set `minimum_depth` to zero. + * - otherwise: + * - SHOULD set `minimum_depth` to a number of blocks it + * considers reasonable to avoid double-spending of the + * funding transaction. */ + /* We override this in openchannel hook if we want zeroconf */ uc->minimum_depth = ld->config.anchor_confirms; /* Declare the new channel to the HSM. */ diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 3e740844c3f5..f059a7eb7200 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -178,7 +178,7 @@ wallet_commit_channel(struct lightningd *ld, funding_sats, push, local_funding, - false, /* !remote_funding_locked */ + false, /* !remote_channel_ready */ NULL, /* no scid yet */ alias_local, /* But maybe we have an alias we want to use? */ NULL, /* They haven't told us an alias yet */ @@ -539,7 +539,7 @@ static void opening_fundee_finished(struct subd *openingd, /* Tell plugins about the success */ notify_channel_opened(ld, &channel->peer->id, &channel->funding_sats, - &channel->funding.txid, channel->remote_funding_locked); + &channel->funding.txid, channel->remote_channel_ready); if (pbase) wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); @@ -1213,8 +1213,12 @@ static struct command_result *json_fundchannel_start(struct command *cmd, /* BOLT #2: * * The sender: - * - SHOULD set `minimum_depth` to a number of blocks it considers - * reasonable to avoid double-spending of the funding transaction. + * - if `channel_type` includes `option_zeroconf`: + * - MUST set `minimum_depth` to zero. + * - otherwise: + * - SHOULD set `minimum_depth` to a number of blocks it + * considers reasonable to avoid double-spending of the + * funding transaction. */ assert(mindepth != NULL); fc->uc->minimum_depth = *mindepth; @@ -1376,7 +1380,7 @@ static struct channel *stub_chan(struct command *cmd, funding_sats, AMOUNT_MSAT(0), AMOUNT_SAT(0), - true, /* !remote_funding_locked */ + true, /* remote_channel_ready */ scid, scid, scid, diff --git a/openingd/dualopend.c b/openingd/dualopend.c index c2de0716b3ff..0c40c0fdc6aa 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -195,7 +195,7 @@ struct state { struct feature_set *our_features; /* Tally of which sides are locked, or not */ - bool funding_locked[NUM_SIDES]; + bool channel_ready[NUM_SIDES]; /* Are we shutting down? */ bool shutdown_sent[NUM_SIDES]; @@ -380,7 +380,7 @@ static void negotiation_failed(struct state *state, static void billboard_update(struct state *state) { - const char *update = billboard_message(tmpctx, state->funding_locked, + const char *update = billboard_message(tmpctx, state->channel_ready, NULL, state->shutdown_sent, 0, /* Always zero? */ @@ -930,9 +930,9 @@ static void handle_tx_sigs(struct state *state, const u8 *msg) open_err_fatal(state, "Bad tx_signatures %s", tal_hex(msg, msg)); - /* Maybe they didn't get our funding_locked message ? */ - if (state->funding_locked[LOCAL] && !state->reconnected) { - status_broken("Got WIRE_TX_SIGNATURES after funding locked " + /* Maybe they didn't get our channel_ready message ? */ + if (state->channel_ready[LOCAL] && !state->reconnected) { + status_broken("Got WIRE_TX_SIGNATURES after channel_ready " "for channel %s, ignoring: %s", type_to_string(tmpctx, struct channel_id, &state->channel_id), @@ -941,10 +941,10 @@ static void handle_tx_sigs(struct state *state, const u8 *msg) } /* On reconnect, we expect them to resend tx_sigs if they haven't - * gotten our funding_locked yet */ - if (state->funding_locked[REMOTE] && !state->reconnected) + * gotten our channel_ready yet */ + if (state->channel_ready[REMOTE] && !state->reconnected) open_err_warn(state, - "tx_signatures sent after funding_locked %s", + "tx_signatures sent after channel_ready %s", tal_hex(msg, msg)); if (!tx_state->psbt) @@ -1128,18 +1128,18 @@ static void init_changeset(struct tx_state *tx_state, struct wally_psbt *psbt) tx_state->changeset = psbt_get_changeset(tx_state, empty_psbt, psbt); } -static u8 *handle_funding_locked(struct state *state, u8 *msg) +static u8 *handle_channel_ready(struct state *state, u8 *msg) { struct channel_id cid; struct pubkey remote_per_commit; - struct tlv_funding_locked_tlvs *tlvs; + struct tlv_channel_ready_tlvs *tlvs; - if (!fromwire_funding_locked(tmpctx, msg, &cid, &remote_per_commit, &tlvs)) - open_err_fatal(state, "Bad funding_locked %s", + if (!fromwire_channel_ready(tmpctx, msg, &cid, &remote_per_commit, &tlvs)) + open_err_fatal(state, "Bad channel_ready %s", tal_hex(msg, msg)); if (!channel_id_eq(&cid, &state->channel_id)) - open_err_fatal(state, "funding_locked ids don't match:" + open_err_fatal(state, "channel_ready ids don't match:" " expected %s, got %s", type_to_string(msg, struct channel_id, &state->channel_id), @@ -1148,21 +1148,21 @@ static u8 *handle_funding_locked(struct state *state, u8 *msg) /* If we haven't gotten their tx_sigs yet, this is a protocol error */ if (!state->tx_state->remote_funding_sigs_rcvd) { open_err_warn(state, - "funding_locked sent before tx_signatures %s", + "channel_ready sent before tx_signatures %s", tal_hex(msg, msg)); } /* We save when the peer locks, so we do the right * thing on reconnects */ - if (!state->funding_locked[REMOTE]) { + if (!state->channel_ready[REMOTE]) { msg = towire_dualopend_peer_locked(NULL, &remote_per_commit); wire_sync_write(REQ_FD, take(msg)); } - state->funding_locked[REMOTE] = true; + state->channel_ready[REMOTE] = true; billboard_update(state); - if (state->funding_locked[LOCAL]) + if (state->channel_ready[LOCAL]) return towire_dualopend_channel_locked(state); return NULL; @@ -1247,8 +1247,8 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state) * startup an RBF */ handle_tx_sigs(state, msg); continue; - case WIRE_FUNDING_LOCKED: - handle_funding_locked(state, msg); + case WIRE_CHANNEL_READY: + handle_channel_ready(state, msg); return NULL; case WIRE_SHUTDOWN: handle_peer_shutdown(state, msg); @@ -1608,7 +1608,7 @@ static bool run_tx_interactive(struct state *state, case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_SHUTDOWN: case WIRE_CLOSING_SIGNED: case WIRE_UPDATE_ADD_HTLC: @@ -3388,19 +3388,19 @@ static void hsm_per_commitment_point(u64 index, struct pubkey *point) tal_hex(tmpctx, msg)); } -static void send_funding_locked(struct state *state) +static void send_channel_ready(struct state *state) { u8 *msg; struct pubkey next_local_per_commit; - struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx); + struct tlv_channel_ready_tlvs *tlvs = tlv_channel_ready_tlvs_new(tmpctx); /* Figure out the next local commit */ hsm_per_commitment_point(1, &next_local_per_commit); - msg = towire_funding_locked(NULL, &state->channel_id, + msg = towire_channel_ready(NULL, &state->channel_id, &next_local_per_commit, tlvs); peer_write(state->pps, take(msg)); - state->funding_locked[LOCAL] = true; + state->channel_ready[LOCAL] = true; billboard_update(state); } @@ -3453,8 +3453,8 @@ static u8 *handle_funding_depth(struct state *state, u8 *msg) /* Tell gossipd the new channel exists before we tell peer. */ tell_gossipd_new_channel(state); - send_funding_locked(state); - if (state->funding_locked[REMOTE]) + send_channel_ready(state); + if (state->channel_ready[REMOTE]) return towire_dualopend_channel_locked(state); return NULL; @@ -3614,17 +3614,17 @@ static void do_reconnect_dance(struct state *state) /* It's possible we sent our sigs, but they didn't get them. * Resend our signatures, just in case */ if (psbt_side_finalized(tx_state->psbt, state->our_role) - && !state->funding_locked[REMOTE]) { + && !state->channel_ready[REMOTE]) { msg = psbt_to_tx_sigs_msg(NULL, state, tx_state->psbt); peer_write(state->pps, take(msg)); } - if (state->funding_locked[LOCAL]) { + if (state->channel_ready[LOCAL]) { status_debug("Retransmitting funding_locked for channel %s", type_to_string(tmpctx, struct channel_id, &state->channel_id)); - send_funding_locked(state); + send_channel_ready(state); } peer_billboard(true, "Reconnected, and reestablished."); @@ -3714,8 +3714,8 @@ static u8 *handle_peer_in(struct state *state) case WIRE_TX_SIGNATURES: handle_tx_sigs(state, msg); return NULL; - case WIRE_FUNDING_LOCKED: - return handle_funding_locked(state, msg); + case WIRE_CHANNEL_READY: + return handle_channel_ready(state, msg); case WIRE_SHUTDOWN: handle_peer_shutdown(state, msg); return NULL; @@ -3833,8 +3833,8 @@ int main(int argc, char *argv[]) = NULL; /*~ We're not locked or shutting down quite yet */ - state->funding_locked[LOCAL] - = state->funding_locked[REMOTE] + state->channel_ready[LOCAL] + = state->channel_ready[REMOTE] = false; state->shutdown_sent[LOCAL] = state->shutdown_sent[REMOTE] @@ -3861,8 +3861,8 @@ int main(int argc, char *argv[]) &state->first_per_commitment_point[REMOTE], &state->tx_state->psbt, &opener, - &state->funding_locked[LOCAL], - &state->funding_locked[REMOTE], + &state->channel_ready[LOCAL], + &state->channel_ready[REMOTE], &state->shutdown_sent[LOCAL], &state->shutdown_sent[REMOTE], &state->upfront_shutdown_script[LOCAL], diff --git a/openingd/openingd.c b/openingd/openingd.c index d2ae1cada07f..3e9272a43f8d 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -839,8 +839,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) /* BOLT #2: * The receiving node MUST fail the channel if: *... - * - It supports `channel_type`, `channel_type` was set, and the - * `type` is not suitable. + * - It supports `channel_type` and `channel_type` was set: + * - if `type` is not suitable. + * - if `type` includes `option_zeroconf` and it does not trust the sender to open an unconfirmed channel. */ if (open_tlvs->channel_type) { state->channel_type = diff --git a/tests/test_closing.py b/tests/test_closing.py index e2cf90dac9f0..f278d9c93a19 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -1785,7 +1785,7 @@ def test_onchain_first_commit(node_factory, bitcoind): coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') # HTLC 1->2, 1 fails just after funding. - disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail'] + disconnects = ['+WIRE_CHANNEL_READY', 'permfail'] # Make locktime different, as we once had them reversed! l1, l2 = node_factory.line_graph(2, opts=[{'disconnect': disconnects, 'plugin': coin_mvt_plugin}, diff --git a/tests/test_connection.py b/tests/test_connection.py index 906e8c80cd0f..3f915c8c6fb4 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -679,7 +679,7 @@ def test_reconnect_no_update(node_factory, executor, bitcoind): reconnects. See comments for details. """ - disconnects = ["-WIRE_FUNDING_LOCKED", "-WIRE_SHUTDOWN"] + disconnects = ["-WIRE_CHANNEL_READY", "-WIRE_SHUTDOWN"] # Allow bad gossip because it might receive WIRE_CHANNEL_UPDATE before # announcement of the disconnection l1 = node_factory.get_node(may_reconnect=True, allow_bad_gossip=True) @@ -715,8 +715,8 @@ def test_reconnect_no_update(node_factory, executor, bitcoind): @pytest.mark.openchannel('v2') def test_reconnect_normal(node_factory): # Should reconnect fine even if locked message gets lost. - disconnects = ['-WIRE_FUNDING_LOCKED', - '+WIRE_FUNDING_LOCKED'] + disconnects = ['-WIRE_CHANNEL_READY', + '+WIRE_CHANNEL_READY'] l1 = node_factory.get_node(disconnect=disconnects, may_reconnect=True) l2 = node_factory.get_node(may_reconnect=True) @@ -2234,7 +2234,7 @@ def test_channel_persistence(node_factory, bitcoind, executor): # Fire off a sendpay request, it'll get interrupted by a restart executor.submit(l1.pay, l2, 10000) # Wait for it to be committed to, i.e., stored in the DB - l1.daemon.wait_for_log('peer_in WIRE_FUNDING_LOCKED') + l1.daemon.wait_for_log('peer_in WIRE_CHANNEL_READY') l1.daemon.wait_for_log('peer_in WIRE_COMMITMENT_SIGNED') # Stop l2, l1 will reattempt to connect diff --git a/tests/test_opening.py b/tests/test_opening.py index abbdac3658d8..7072e82165d4 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -1274,13 +1274,13 @@ def test_zeroconf_mindepth(bitcoind, node_factory): assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 2}] bitcoind.generate_block(2, wait_for_mempool=1) # Confirm on the l2 side. - l2.daemon.wait_for_log(r'peer_out WIRE_FUNDING_LOCKED') + l2.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY') # l1 should not be sending funding_locked/channel_ready yet, it is # configured to wait for 6 confirmations. - assert not l1.daemon.is_in_log(r'peer_out WIRE_FUNDING_LOCKED') + assert not l1.daemon.is_in_log(r'peer_out WIRE_CHANNEL_READY') bitcoind.generate_block(4) # Confirm on the l2 side. - l1.daemon.wait_for_log(r'peer_out WIRE_FUNDING_LOCKED') + l1.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY') wait_for(lambda: l1.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL") wait_for(lambda: l2.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL") @@ -1318,11 +1318,11 @@ def test_zeroconf_open(bitcoind, node_factory): assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}] l1.daemon.wait_for_logs([ - r'peer_in WIRE_FUNDING_LOCKED', + r'peer_in WIRE_CHANNEL_READY', r'Peer told us that they\'ll use alias=[0-9x]+ for this channel', ]) l2.daemon.wait_for_logs([ - r'peer_in WIRE_FUNDING_LOCKED', + r'peer_in WIRE_CHANNEL_READY', r'Peer told us that they\'ll use alias=[0-9x]+ for this channel', ]) @@ -1606,8 +1606,8 @@ def test_zeroconf_multichan_forward(node_factory): l2.fundwallet(10**7) l2.rpc.fundchannel(l3.info['id'], 2 * 10**6, mindepth=0) - l2.daemon.wait_for_log(r'peer_in WIRE_FUNDING_LOCKED') - l3.daemon.wait_for_log(r'peer_in WIRE_FUNDING_LOCKED') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_READY') + l3.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_READY') inv = l3.rpc.invoice(amount_msat=10000, label='lbl1', description='desc')['bolt11'] l1.rpc.pay(inv) diff --git a/wallet/wallet.c b/wallet/wallet.c index 9cc9e8e58caa..8ba81f9ffa73 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1922,7 +1922,7 @@ void wallet_channel_save(struct wallet *w, struct channel *chan) db_bind_int(stmt, 11, chan->funding.n); db_bind_amount_sat(stmt, 12, &chan->funding_sats); db_bind_amount_sat(stmt, 13, &chan->our_funds); - db_bind_int(stmt, 14, chan->remote_funding_locked); + db_bind_int(stmt, 14, chan->remote_channel_ready); db_bind_amount_msat(stmt, 15, &chan->push); db_bind_amount_msat(stmt, 16, &chan->our_msat); diff --git a/wire/extracted_peer_03_openchannelv2.patch b/wire/extracted_peer_03_openchannelv2.patch index c32c95529883..81b5ce8cfce0 100644 --- a/wire/extracted_peer_03_openchannelv2.patch +++ b/wire/extracted_peer_03_openchannelv2.patch @@ -42,9 +42,9 @@ msgdata,open_channel,chain_hash,chain_hash, msgdata,open_channel,temporary_channel_id,byte,32 @@ -86,6 +116,56 @@ - msgtype,funding_locked,36 - msgdata,funding_locked,channel_id,channel_id, - msgdata,funding_locked,next_per_commitment_point,point, + msgdata,channel_ready,tlvs,channel_ready_tlvs, + tlvtype,channel_ready_tlvs,short_channel_id,1 + tlvdata,channel_ready_tlvs,short_channel_id,alias,short_channel_id, +msgtype,open_channel2,64 +msgdata,open_channel2,chain_hash,chain_hash, +msgdata,open_channel2,channel_id,channel_id, diff --git a/wire/extracted_peer_06_zeroconf.patch b/wire/extracted_peer_06_zeroconf.patch deleted file mode 100644 index 5084b00cb7e3..000000000000 --- a/wire/extracted_peer_06_zeroconf.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv -index a028ddc66..fc24b61ef 100644 ---- a/wire/peer_wire.csv -+++ b/wire/peer_wire.csv -@@ -126,6 +126,9 @@ msgdata,funding_signed,signature,signature, - msgtype,funding_locked,36 - msgdata,funding_locked,channel_id,channel_id, - msgdata,funding_locked,next_per_commitment_point,point, -+msgdata,funding_locked,tlvs,funding_locked_tlvs, -+tlvtype,funding_locked_tlvs,alias,1 -+tlvdata,funding_locked_tlvs,alias,scid,short_channel_id, - msgtype,open_channel2,64 - msgdata,open_channel2,chain_hash,chain_hash, - msgdata,open_channel2,channel_id,channel_id, diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 0aca55a5d488..2bd0eea71119 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -12,7 +12,7 @@ static bool unknown_type(enum peer_wire t) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_SHUTDOWN: case WIRE_CLOSING_SIGNED: case WIRE_UPDATE_ADD_HTLC: @@ -75,7 +75,7 @@ bool is_msg_for_gossipd(const u8 *cursor) case WIRE_ACCEPT_CHANNEL: case WIRE_FUNDING_CREATED: case WIRE_FUNDING_SIGNED: - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: case WIRE_SHUTDOWN: case WIRE_CLOSING_SIGNED: case WIRE_UPDATE_ADD_HTLC: @@ -242,9 +242,9 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id) * 2. data: * * [`channel_id`:`channel_id`] */ - case WIRE_FUNDING_LOCKED: + case WIRE_CHANNEL_READY: /* BOLT #2: - * 1. type: 36 (`funding_locked`) + * 1. type: 36 (`channel_ready`) * 2. data: * * [`channel_id`:`channel_id`] */ diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv index d400da1b8a67..54f48115666a 100644 --- a/wire/peer_wire.csv +++ b/wire/peer_wire.csv @@ -123,12 +123,12 @@ msgdata,funding_created,signature,signature, msgtype,funding_signed,35 msgdata,funding_signed,channel_id,channel_id, msgdata,funding_signed,signature,signature, -msgtype,funding_locked,36 -msgdata,funding_locked,channel_id,channel_id, -msgdata,funding_locked,next_per_commitment_point,point, -msgdata,funding_locked,tlvs,funding_locked_tlvs, -tlvtype,funding_locked_tlvs,alias,1 -tlvdata,funding_locked_tlvs,alias,scid,short_channel_id, +msgtype,channel_ready,36 +msgdata,channel_ready,channel_id,channel_id, +msgdata,channel_ready,second_per_commitment_point,point, +msgdata,channel_ready,tlvs,channel_ready_tlvs, +tlvtype,channel_ready_tlvs,short_channel_id,1 +tlvdata,channel_ready_tlvs,short_channel_id,alias,short_channel_id, msgtype,open_channel2,64 msgdata,open_channel2,chain_hash,chain_hash, msgdata,open_channel2,channel_id,channel_id, diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index 1be1c016b93f..d9df608b812b 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -157,10 +157,10 @@ struct msg_channel_update_opt_htlc_max { struct bitcoin_blkid chain_hash; struct short_channel_id short_channel_id; }; -struct msg_funding_locked { +struct msg_channel_ready { struct channel_id channel_id; struct pubkey next_per_commitment_point; - struct tlv_funding_locked_tlvs *tlvs; + struct tlv_channel_ready_tlvs *tlvs; }; struct msg_announcement_signatures { struct channel_id channel_id; @@ -477,20 +477,20 @@ static struct msg_channel_update_opt_htlc_max return tal_free(s); } -static void *towire_struct_funding_locked(const tal_t *ctx, - const struct msg_funding_locked *s) +static void *towire_struct_channel_ready(const tal_t *ctx, + const struct msg_channel_ready *s) { - return towire_funding_locked(ctx, + return towire_channel_ready(ctx, &s->channel_id, &s->next_per_commitment_point, s->tlvs); } -static struct msg_funding_locked *fromwire_struct_funding_locked(const tal_t *ctx, const void *p) +static struct msg_channel_ready *fromwire_struct_channel_ready(const tal_t *ctx, const void *p) { - struct msg_funding_locked *s = tal(ctx, struct msg_funding_locked); + struct msg_channel_ready *s = tal(ctx, struct msg_channel_ready); - if (fromwire_funding_locked(ctx, + if (fromwire_channel_ready(ctx, p, &s->channel_id, &s->next_per_commitment_point, @@ -816,13 +816,13 @@ static bool channel_announcement_eq(const struct msg_channel_announcement *a, && eq_between(a, b, bitcoin_key_1, bitcoin_key_2); } -static bool funding_locked_eq(const struct msg_funding_locked *a, - const struct msg_funding_locked *b) +static bool channel_ready_eq(const struct msg_channel_ready *a, + const struct msg_channel_ready *b) { if (!eq_upto(a, b, tlvs)) return false; - return eq_tlv(a, b, alias, short_channel_id_eq); + return eq_tlv(a, b, short_channel_id, short_channel_id_eq); } static bool announcement_signatures_eq(const struct msg_announcement_signatures *a, @@ -1009,7 +1009,7 @@ static bool node_announcement_eq(const struct msg_node_announcement *a, int main(int argc, char *argv[]) { struct msg_channel_announcement ca, *ca2; - struct msg_funding_locked fl, *fl2; + struct msg_channel_ready fl, *fl2; struct msg_announcement_signatures as, *as2; struct msg_update_fail_htlc ufh, *ufh2; struct msg_commitment_signed cs, *cs2; @@ -1048,15 +1048,15 @@ int main(int argc, char *argv[]) test_corruption(&ca, ca2, channel_announcement); memset(&fl, 2, sizeof(fl)); - fl.tlvs = tlv_funding_locked_tlvs_new(ctx); - fl.tlvs->alias = tal(ctx, struct short_channel_id); - set_scid(fl.tlvs->alias); + fl.tlvs = tlv_channel_ready_tlvs_new(ctx); + fl.tlvs->short_channel_id = tal(ctx, struct short_channel_id); + set_scid(fl.tlvs->short_channel_id); set_pubkey(&fl.next_per_commitment_point); - msg = towire_struct_funding_locked(ctx, &fl); - fl2 = fromwire_struct_funding_locked(ctx, msg); - assert(funding_locked_eq(&fl, fl2)); - test_corruption_tlv(&fl, fl2, funding_locked); + msg = towire_struct_channel_ready(ctx, &fl); + fl2 = fromwire_struct_channel_ready(ctx, msg); + assert(channel_ready_eq(&fl, fl2)); + test_corruption_tlv(&fl, fl2, channel_ready); memset(&as, 2, sizeof(as));