diff --git a/channeld/channeld.c b/channeld/channeld.c index 5d1e6d25d4b3..d6a68959118e 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1908,12 +1908,19 @@ static void handle_unexpected_reestablish(struct peer *peer, const u8 *msg) u64 next_revocation_number; struct secret your_last_per_commitment_secret; struct pubkey my_current_per_commitment_point; +#if EXPERIMENTAL_FEATURES + struct tlv_channel_reestablish_tlvs *tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif if (!fromwire_channel_reestablish(msg, &channel_id, &next_commitment_number, &next_revocation_number, &your_last_per_commitment_secret, - &my_current_per_commitment_point)) + &my_current_per_commitment_point +#if EXPERIMENTAL_FEATURES + , tlvs +#endif + )) peer_failed_warn(peer->pps, &peer->channel_id, "Bad channel_reestablish %s", tal_hex(peer, msg)); @@ -2452,6 +2459,9 @@ static void peer_reconnect(struct peer *peer, struct secret last_local_per_commitment_secret; bool dataloss_protect, check_extra_fields; const u8 **premature_msgs = tal_arr(peer, const u8 *, 0); +#if EXPERIMENTAL_FEATURES + struct tlv_channel_reestablish_tlvs *send_tlvs, *recv_tlvs; +#endif dataloss_protect = feature_negotiated(peer->our_features, peer->their_features, @@ -2466,6 +2476,10 @@ static void peer_reconnect(struct peer *peer, get_per_commitment_point(peer->next_index[LOCAL] - 1, &my_current_per_commitment_point, NULL); +#if EXPERIMENTAL_FEATURES + send_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif + /* BOLT #2: * * - upon reconnection: @@ -2503,14 +2517,22 @@ static void peer_reconnect(struct peer *peer, peer->revocations_received, last_remote_per_commit_secret, /* Can send any (valid) point here */ - &peer->remote_per_commit); + &peer->remote_per_commit +#if EXPERIMENTAL_FEATURES + , send_tlvs +#endif + ); } else { msg = towire_channel_reestablish (NULL, &peer->channel_id, peer->next_index[LOCAL], peer->revocations_received, last_remote_per_commit_secret, - &my_current_per_commitment_point); + &my_current_per_commitment_point +#if EXPERIMENTAL_FEATURES + , send_tlvs +#endif + ); } sync_crypto_write(peer->pps, take(msg)); @@ -2530,12 +2552,20 @@ static void peer_reconnect(struct peer *peer, msg) || capture_premature_msg(&premature_msgs, msg)); +#if EXPERIMENTAL_FEATURES + recv_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif + if (!fromwire_channel_reestablish(msg, &channel_id, &next_commitment_number, &next_revocation_number, &last_local_per_commitment_secret, - &remote_current_per_commitment_point)) { + &remote_current_per_commitment_point +#if EXPERIMENTAL_FEATURES + , recv_tlvs +#endif + )) { peer_failed_warn(peer->pps, &peer->channel_id, "bad reestablish msg: %s %s", diff --git a/closingd/closingd.c b/closingd/closingd.c index 80c10adcaa87..83bffe4016c5 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -176,6 +176,9 @@ static void do_reconnect(struct per_peer_state *pps, struct pubkey my_current_per_commitment_point, next_commitment_point; struct secret their_secret; struct tlv_shutdown_tlvs *tlvs; +#if EXPERIMENTAL_FEATURES + struct tlv_channel_reestablish_tlvs *reestablish_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif my_current_per_commitment_point = get_per_commitment_point(next_index[LOCAL]-1); @@ -201,7 +204,11 @@ static void do_reconnect(struct per_peer_state *pps, next_index[LOCAL], revocations_received, last_remote_per_commit_secret, - &my_current_per_commitment_point); + &my_current_per_commitment_point +#if EXPERIMENTAL_FEATURES + , reestablish_tlvs +#endif + ); sync_crypto_write(pps, take(msg)); /* They might have already sent reestablish, which triggered us */ @@ -221,7 +228,11 @@ static void do_reconnect(struct per_peer_state *pps, &next_local_commitment_number, &next_remote_revocation_number, &their_secret, - &next_commitment_point)) { + &next_commitment_point +#if EXPERIMENTAL_FEATURES + , reestablish_tlvs +#endif + )) { peer_failed_warn(pps, channel_id, "bad reestablish msg: %s %s", peer_wire_name(fromwire_peektype(channel_reestablish)), diff --git a/openingd/dualopend.c b/openingd/dualopend.c index a264bbf208d4..d8cc546eb57c 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -3164,6 +3164,9 @@ static void do_reconnect_dance(struct state *state) last_remote_per_commit_secret; struct pubkey remote_current_per_commit_point; struct tx_state *tx_state = state->tx_state; +#if EXPERIMENTAL_FEATURES + struct tlv_channel_reestablish_tlvs *tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif /* BOLT #2: * - if `next_revocation_number` equals 0: @@ -3177,7 +3180,11 @@ static void do_reconnect_dance(struct state *state) msg = towire_channel_reestablish (NULL, &state->channel_id, 1, 0, &last_remote_per_commit_secret, - &state->first_per_commitment_point[LOCAL]); + &state->first_per_commitment_point[LOCAL] +#if EXPERIMENTAL_FEATURES + , tlvs +#endif + ); sync_crypto_write(state->pps, take(msg)); peer_billboard(false, "Sent reestablish, waiting for theirs"); @@ -3200,7 +3207,11 @@ static void do_reconnect_dance(struct state *state) &next_commitment_number, &next_revocation_number, &last_local_per_commit_secret, - &remote_current_per_commit_point)) + &remote_current_per_commit_point +#if EXPERIMENTAL_FEATURES + , tlvs +#endif + )) open_err_fatal(state, "Bad reestablish msg: %s %s", peer_wire_name(fromwire_peektype(msg)), tal_hex(msg, msg)); diff --git a/wire/extracted_peer_exp_upgradable.patch b/wire/extracted_peer_exp_upgradable.patch new file mode 100644 index 000000000000..db26af74680e --- /dev/null +++ b/wire/extracted_peer_exp_upgradable.patch @@ -0,0 +1,21 @@ +--- wire/peer_wire.csv 2021-05-09 15:44:59.166135652 +0930 ++++ wire/peer_wire.csv.raw 2021-05-11 09:59:31.695459756 +0930 +@@ -221,6 +131,18 @@ + msgdata,channel_reestablish,next_revocation_number,u64, + msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32 + msgdata,channel_reestablish,my_current_per_commitment_point,point, ++msgdata,channel_reestablish,tlvs,channel_reestablish_tlvs, ++tlvtype,channel_reestablish_tlvs,next_to_send,1 ++tlvdata,channel_reestablish_tlvs,next_to_send,commitment_number,tu64, ++tlvtype,channel_reestablish_tlvs,desired_type,3 ++tlvdata,channel_reestablish_tlvs,desired_type,type,channel_type, ++tlvtype,channel_reestablish_tlvs,current_type,5 ++tlvdata,channel_reestablish_tlvs,current_type,type,channel_type, ++tlvtype,channel_reestablish_tlvs,upgradable,7 ++tlvdata,channel_reestablish_tlvs,upgradable,upgrades,channel_type,... ++subtype,channel_type ++subtypedata,channel_type,len,u16, ++subtypedata,channel_type,features,byte,len + msgtype,announcement_signatures,259 + msgdata,announcement_signatures,channel_id,channel_id, + msgdata,announcement_signatures,short_channel_id,short_channel_id, diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 1f8fc3731306..afc60a2203bb 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -124,10 +124,17 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id) struct bitcoin_blkid ignored_chainhash; struct secret ignored_secret; struct tlv_open_channel_tlvs *tlvs = tlv_open_channel_tlvs_new(tmpctx); +#if EXPERIMENTAL_FEATURES + struct tlv_channel_reestablish_tlvs *reestab_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx); +#endif if (fromwire_channel_reestablish(in_pkt, channel_id, &ignored_u64, &ignored_u64, - &ignored_secret, &ignored_pubkey)) + &ignored_secret, &ignored_pubkey +#if EXPERIMENTAL_FEATURES + , reestab_tlvs +#endif + )) return true; if (fromwire_open_channel(in_pkt, &ignored_chainhash, channel_id, &ignored_sat,