5151#define HSM_FD 4
5252
5353#define VALID_STFU_MESSAGE (msg ) \
54- ((msg) == WIRE_SPLICE || \
54+ ((msg) == WIRE_SPLICE_INIT || \
5555 (msg) == WIRE_SPLICE_ACK || \
5656 (msg) == WIRE_TX_INIT_RBF || \
5757 (msg) == WIRE_TX_ACK_RBF || \
@@ -1220,7 +1220,7 @@ static u8 *send_commit_part(const tal_t *ctx,
12201220 (int )splice_amnt , (int )remote_splice_amnt ,
12211221 remote_index );
12221222
1223- cs_tlv -> splice_info = tal_dup (cs_tlv , struct bitcoin_txid , & funding -> txid );
1223+ cs_tlv -> funding_txid = tal_dup (cs_tlv , struct bitcoin_txid , & funding -> txid );
12241224 }
12251225
12261226 txs = channel_txs (tmpctx , funding , funding_sats , & htlc_map ,
@@ -1319,8 +1319,8 @@ static void send_message_batch(struct peer *peer, u8 **msgs)
13191319
13201320 /* Build the `start_batch` msg now so know it's size */
13211321 tlvs = tlv_start_batch_tlvs_new (tmpctx );
1322- tlvs -> batch_info = tal (tlvs , u16 );
1323- * tlvs -> batch_info = WIRE_COMMITMENT_SIGNED ;
1322+ tlvs -> message_type = tal (tlvs , u16 );
1323+ * tlvs -> message_type = WIRE_COMMITMENT_SIGNED ;
13241324 batch_msg = towire_start_batch (tmpctx , & peer -> channel_id ,
13251325 tal_count (msgs ), tlvs );
13261326 size += tal_bytelen (batch_msg ) + hdr_size ;
@@ -2053,7 +2053,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20532053 * - If `funding_txid` is missing in one of the `commitment_signed` messages:
20542054 * - MUST send an `error` and fail the channel.
20552055 */
2056- if (!cs_tlv -> splice_info )
2056+ if (!cs_tlv -> funding_txid )
20572057 peer_failed_err (peer -> pps , & peer -> channel_id ,
20582058 "Must send funding_txid when sending"
20592059 " a commitment batch." );
@@ -2065,7 +2065,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20652065 * - MUST send an `error` and fail the channel.
20662066 */
20672067 if (!tal_count (peer -> splice_state -> inflights )
2068- && !bitcoin_txid_eq (cs_tlv -> splice_info ,
2068+ && !bitcoin_txid_eq (cs_tlv -> funding_txid ,
20692069 & peer -> channel -> funding .txid ))
20702070 peer_failed_err (peer -> pps , & peer -> channel_id ,
20712071 "Commitment batch is is missing our"
@@ -2077,7 +2077,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20772077 * - If `funding_txid` is missing in one of the `commitment_signed` messages:
20782078 * - MUST send an `error` and fail the channel.
20792079 */
2080- if (commit_index && !cs_tlv -> splice_info )
2080+ if (commit_index && !cs_tlv -> funding_txid )
20812081 peer_failed_err (peer -> pps , & peer -> channel_id ,
20822082 "Must send funding_txid when sending"
20832083 " a commitment batch" );
@@ -2123,14 +2123,14 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21232123 status_debug ("handle_peer_commit_sig for inflight outpoint %s" ,
21242124 fmt_bitcoin_txid (tmpctx , & outpoint .txid ));
21252125
2126- if (cs_tlv -> splice_info
2126+ if (cs_tlv -> funding_txid
21272127 && !bitcoin_txid_eq (& outpoint .txid ,
2128- cs_tlv -> splice_info ))
2128+ cs_tlv -> funding_txid ))
21292129 peer_failed_err (peer -> pps , & peer -> channel_id ,
21302130 "Expected commit sig message for %s but"
21312131 " got %s" ,
21322132 fmt_bitcoin_txid (tmpctx , & outpoint .txid ),
2133- fmt_bitcoin_txid (tmpctx , cs_tlv -> splice_info ));
2133+ fmt_bitcoin_txid (tmpctx , cs_tlv -> funding_txid ));
21342134 }
21352135 else {
21362136 outpoint = peer -> channel -> funding ;
@@ -2174,7 +2174,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21742174 peer_failed_warn (peer -> pps , & peer -> channel_id ,
21752175 "Bad commit_sig signature %" PRIu64 " %s for tx"
21762176 " %s wscript %s key %s feerate %u. Outpoint"
2177- " %s, funding_sats: %s, splice_info : %s,"
2177+ " %s, funding_sats: %s, funding_txid : %s,"
21782178 " inflight splice count: %zu" ,
21792179 local_index ,
21802180 fmt_bitcoin_signature (msg , & commit_sig ),
@@ -2184,9 +2184,9 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21842184 channel_feerate (peer -> channel , LOCAL ),
21852185 fmt_bitcoin_outpoint (tmpctx , & outpoint ),
21862186 fmt_amount_sat (tmpctx , funding_sats ),
2187- cs_tlv && cs_tlv -> splice_info
2187+ cs_tlv && cs_tlv -> funding_txid
21882188 ? fmt_bitcoin_txid (tmpctx ,
2189- cs_tlv -> splice_info )
2189+ cs_tlv -> funding_txid )
21902190 : "N/A" ,
21912191 tal_count (peer -> splice_state -> inflights ));
21922192 }
@@ -2350,10 +2350,10 @@ static int commit_index_from_msg(const u8 *msg, struct peer *peer)
23502350 fromwire_commitment_signed (tmpctx , msg , & channel_id , & commit_sig .s ,
23512351 & raw_sigs , & cs_tlv );
23522352
2353- if (!cs_tlv || !cs_tlv -> splice_info )
2353+ if (!cs_tlv || !cs_tlv -> funding_txid )
23542354 return -1 ;
23552355
2356- funding_txid = * cs_tlv -> splice_info ;
2356+ funding_txid = * cs_tlv -> funding_txid ;
23572357
23582358 if (bitcoin_txid_eq (& funding_txid , & peer -> channel -> funding .txid ))
23592359 return 0 ;
@@ -2451,11 +2451,11 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
24512451 " [%" PRIu16 "/%" PRIu16 "]" ,
24522452 tal_hex (sub_msg , sub_msg ), i , batch_size );
24532453
2454- if (!sub_cs_tlv -> splice_info )
2454+ if (!sub_cs_tlv -> funding_txid )
24552455 peer_failed_warn (peer -> pps , & peer -> channel_id ,
24562456 "commit_sig %s in commit_sig batch:"
24572457 " [%" PRIu16 "/%" PRIu16 "] missing"
2458- " splice_info " ,
2458+ " funding_txid " ,
24592459 tal_hex (sub_msg , sub_msg ), i , batch_size );
24602460
24612461 msg_batch [i ] = sub_msg ;
@@ -2486,12 +2486,12 @@ static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
24862486 peer_failed_warn (peer -> pps , & peer -> channel_id ,
24872487 "Bad start_batch %s" , tal_hex (msg , msg ));
24882488
2489- if (!tlvs || !tlvs -> batch_info
2490- || * tlvs -> batch_info != WIRE_COMMITMENT_SIGNED ) {
2489+ if (!tlvs || !tlvs -> message_type
2490+ || * tlvs -> message_type != WIRE_COMMITMENT_SIGNED ) {
24912491 status_unusual ("Ignoring Unrecognized start_batch message type"
24922492 " %s, expected WIRE_COMMITMENT_SIGNED." ,
2493- tlvs && tlvs -> batch_info
2494- ? peer_wire_name (* tlvs -> batch_info )
2493+ tlvs && tlvs -> message_type
2494+ ? peer_wire_name (* tlvs -> message_type )
24952495 : "N/A" );
24962496 return ;
24972497 }
@@ -2885,7 +2885,7 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)
28852885 struct channel_id cid ;
28862886 struct bitcoin_txid txid ;
28872887
2888- struct tlv_txsigs_tlvs * txsig_tlvs = tlv_txsigs_tlvs_new (tmpctx );
2888+ struct tlv_tx_signatures_tlvs * txsig_tlvs = tlv_tx_signatures_tlvs_new (tmpctx );
28892889
28902890 /* In a rare case, a v2 peer may re-send a tx_sigs message.
28912891 * This happens when they've/we've exchanged channel_ready,
@@ -3793,7 +3793,7 @@ static void resume_splice_negotiation(struct peer *peer,
37933793 struct bitcoin_tx * final_tx ;
37943794 struct bitcoin_txid final_txid ;
37953795 u8 * * wit_stack ;
3796- struct tlv_txsigs_tlvs * txsig_tlvs , * their_txsigs_tlvs ;
3796+ struct tlv_tx_signatures_tlvs * txsig_tlvs , * their_txsigs_tlvs ;
37973797 const u8 * msg_received ;
37983798 struct witness * * inws ;
37993799 struct bitcoin_signature * their_sig ;
@@ -3898,7 +3898,7 @@ static void resume_splice_negotiation(struct peer *peer,
38983898 fmt_bitcoin_signature (tmpctx , & splice_sig ),
38993899 fmt_wally_psbt (tmpctx , current_psbt ));
39003900
3901- txsig_tlvs = tlv_txsigs_tlvs_new (tmpctx );
3901+ txsig_tlvs = tlv_tx_signatures_tlvs_new (tmpctx );
39023902 txsig_tlvs -> shared_input_signature = & splice_sig .s ;
39033903
39043904 /* DTODO: is this finalize call required? */
@@ -3965,7 +3965,7 @@ static void resume_splice_negotiation(struct peer *peer,
39653965 " WIRE_TX_SIGNATURES)" ,
39663966 peer_wire_name (type ));
39673967
3968- their_txsigs_tlvs = tlv_txsigs_tlvs_new (tmpctx );
3968+ their_txsigs_tlvs = tlv_tx_signatures_tlvs_new (tmpctx );
39693969 if (!fromwire_tx_signatures (tmpctx , msg , & cid ,
39703970 & inflight -> outpoint .txid ,
39713971 cast_const3 (struct witness * * * ,
@@ -4224,15 +4224,17 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
42244224
42254225 type = fromwire_peektype (inmsg );
42264226
4227- if (type == WIRE_SPLICE ) {
4228- if (!fromwire_splice (inmsg ,
4229- & channel_id ,
4230- & peer -> splicing -> opener_relative ,
4231- & funding_feerate_perkw ,
4232- & locktime ,
4233- & peer -> splicing -> remote_funding_pubkey ))
4227+ if (type == WIRE_SPLICE_INIT ) {
4228+ struct tlv_splice_init_tlvs * splice_init_tlvs ;
4229+ if (!fromwire_splice_init (tmpctx , inmsg ,
4230+ & channel_id ,
4231+ & peer -> splicing -> opener_relative ,
4232+ & funding_feerate_perkw ,
4233+ & locktime ,
4234+ & peer -> splicing -> remote_funding_pubkey ,
4235+ & splice_init_tlvs ))
42344236 peer_failed_warn (peer -> pps , & peer -> channel_id ,
4235- "Bad wire_splice %s" ,
4237+ "Bad wire_splice_init %s" ,
42364238 tal_hex (tmpctx , inmsg ));
42374239 if (last_inflight (peer )) {
42384240 peer_failed_warn (peer -> pps , & peer -> channel_id ,
@@ -4282,11 +4284,12 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
42824284 /* TODO: Add plugin hook for user to adjust accepter amount */
42834285 peer -> splicing -> accepter_relative = 0 ;
42844286
4285- if (type == WIRE_SPLICE ) {
4287+ if (type == WIRE_SPLICE_INIT ) {
42864288 msg = towire_splice_ack (NULL ,
42874289 & peer -> channel_id ,
42884290 peer -> splicing -> accepter_relative ,
4289- & peer -> channel -> funding_pubkey [LOCAL ]);
4291+ & peer -> channel -> funding_pubkey [LOCAL ],
4292+ NULL );
42904293 } else if (type == WIRE_TX_INIT_RBF ) {
42914294 ack_rbf_tlvs = tlv_tx_ack_rbf_tlvs_new (tmpctx );
42924295 ack_rbf_tlvs -> funding_output_contribution = tal (ack_rbf_tlvs , s64 );
@@ -4415,10 +4418,12 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
44154418 type = fromwire_peektype (inmsg );
44164419
44174420 if (type == WIRE_SPLICE_ACK ) {
4418- if (!fromwire_splice_ack (inmsg ,
4421+ struct tlv_splice_ack_tlvs * splice_ack_tlvs ;
4422+ if (!fromwire_splice_ack (tmpctx , inmsg ,
44194423 & channel_id ,
44204424 & peer -> splicing -> accepter_relative ,
4421- & peer -> splicing -> remote_funding_pubkey ))
4425+ & peer -> splicing -> remote_funding_pubkey ,
4426+ & splice_ack_tlvs ))
44224427 peer_failed_warn (peer -> pps , & peer -> channel_id ,
44234428 "Bad wire_splice_ack %s" ,
44244429 tal_hex (tmpctx , inmsg ));
@@ -4928,12 +4933,13 @@ static void handle_splice_stfu_success(struct peer *peer)
49284933 u8 * msg ;
49294934 struct tlv_tx_init_rbf_tlvs * init_rbf_tlvs ;
49304935 if (!last_inflight (peer )) {
4931- msg = towire_splice (tmpctx ,
4932- & peer -> channel_id ,
4933- peer -> splicing -> opener_relative ,
4934- peer -> splicing -> feerate_per_kw ,
4935- peer -> splicing -> current_psbt -> fallback_locktime ,
4936- & peer -> channel -> funding_pubkey [LOCAL ]);
4936+ msg = towire_splice_init (tmpctx ,
4937+ & peer -> channel_id ,
4938+ peer -> splicing -> opener_relative ,
4939+ peer -> splicing -> feerate_per_kw ,
4940+ peer -> splicing -> current_psbt -> fallback_locktime ,
4941+ & peer -> channel -> funding_pubkey [LOCAL ],
4942+ NULL );
49374943 }
49384944 else { /* RBF attempt */
49394945 init_rbf_tlvs = tlv_tx_init_rbf_tlvs_new (tmpctx );
@@ -5191,7 +5197,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
51915197 case WIRE_STFU :
51925198 handle_stfu (peer , msg );
51935199 return ;
5194- case WIRE_SPLICE :
5200+ case WIRE_SPLICE_INIT :
51955201 case WIRE_TX_INIT_RBF :
51965202 splice_accepter (peer , msg );
51975203 return ;
@@ -5967,13 +5973,19 @@ static void peer_reconnect(struct peer *peer,
59675973
59685974 /* BOLT #2:
59695975 *
5970- * - if `next_commitment_number` is 1 in both the
5971- * `channel_reestablish` it sent and received:
5972- * - MUST retransmit `channel_ready`.
5973- * - otherwise:
5974- * - MUST NOT retransmit `channel_ready`, but MAY send `channel_ready` with
5975- * a different `short_channel_id` `alias` field.
5976+ * A node:
5977+ * - if `next_commitment_number` is zero:
5978+ * - MUST immediately fail the channel and broadcast any relevant latest commitment
5979+ * transaction.
5980+ * - if `next_commitment_number` is 1 in both the `channel_reestablish` it
5981+ * sent and received, and none of those `channel_reestablish` messages
5982+ * contain `my_current_funding_locked` or `next_funding` for a splice transaction:
5983+ * - MUST retransmit `channel_ready`.
5984+ * - otherwise:
5985+ * - MUST NOT retransmit `channel_ready`, but MAY send `channel_ready` with
5986+ * a different `short_channel_id` `alias` field.
59765987 */
5988+
59775989 if (peer -> channel_ready [LOCAL ]
59785990 && peer -> next_index [LOCAL ] == 1
59795991 && next_commitment_number == 1
0 commit comments