@@ -431,8 +431,6 @@ static void check_mutual_splice_locked(struct peer *peer)
431431 fmt_bitcoin_txid (tmpctx ,
432432 & peer -> splice_state -> locked_txid ));
433433
434- peer -> splice_state -> await_commitment_succcess = true;
435-
436434 /* This splice_locked event is used, so reset the flags to false */
437435 peer -> splice_state -> locked_ready [LOCAL ] = false;
438436 peer -> splice_state -> locked_ready [REMOTE ] = false;
@@ -1670,8 +1668,6 @@ static void send_revocation(struct peer *peer,
16701668 master_wait_sync_reply (tmpctx , peer , take (msg_for_master ),
16711669 WIRE_CHANNELD_GOT_COMMITSIG_REPLY );
16721670
1673- peer -> splice_state -> await_commitment_succcess = false;
1674-
16751671 /* Now that the master has persisted the new commitment advance the HSMD
16761672 * and fetch the revocation secret for the old one. */
16771673 msg = make_revocation_msg (peer , peer -> next_index [LOCAL ]- 2 ,
@@ -1990,30 +1986,44 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
19901986 peer_failed_warn (peer -> pps , & peer -> channel_id ,
19911987 "Bad commit_sig %s" , tal_hex (msg , msg ));
19921988
1993- /* BOLT-0d8b701614b09c6ee4172b04da2203e73deec7e2 #2:
1994- * Once a node has received and sent `splice_locked`:
1995- * - Until sending OR receiving of `revoke_and_ack`
1996- * ...
1997- * - MUST ignore `commitment_signed` messages where `splice_channel_id`
1998- * does not match the `channel_id` of the confirmed splice. */
1999- if (peer -> splice_state -> await_commitment_succcess
2000- && !tal_count (peer -> splice_state -> inflights ) && cs_tlv && cs_tlv -> splice_info ) {
2001- if (!bitcoin_txid_eq (& peer -> channel -> funding .txid ,
2002- cs_tlv -> splice_info )) {
2003- status_info ("Ignoring stale commit_sig for channel_id"
2004- " %s, as %s is locked in now." ,
2005- fmt_bitcoin_txid (tmpctx ,
2006- cs_tlv -> splice_info ),
2007- fmt_bitcoin_txid (tmpctx ,
2008- & peer -> channel -> funding .txid ));
2009- return NULL ;
2010- }
1989+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
1990+ * - If the sending node sent `start_batch` and we are processing a batch of
1991+ * `commitment_signed` messages:
1992+ */
1993+ if (msg_batch ) {
1994+
1995+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
1996+ * - If `funding_txid` is missing in one of the `commitment_signed` messages:
1997+ * - MUST send an `error` and fail the channel.
1998+ */
1999+ if (!cs_tlv -> splice_info )
2000+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2001+ "Must send funding_txid when sending"
2002+ " a commitment batch." );
2003+
2004+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2005+ * - Otherwise (no pending splice transactions):
2006+ *...
2007+ * - If `commitment_signed` is missing for the current funding transaction:
2008+ * - MUST send an `error` and fail the channel.
2009+ */
2010+ if (!tal_count (peer -> splice_state -> inflights )
2011+ && !bitcoin_txid_eq (cs_tlv -> splice_info ,
2012+ & peer -> channel -> funding .txid ))
2013+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2014+ "Commitment batch is is missing our"
2015+ " current funding transaction %s" ,
2016+ fmt_bitcoin_txid (tmpctx , & peer -> channel -> funding .txid ));
20112017 }
20122018
2013- /* In a race we can get here with a commitsig with too many splices
2014- * attached. In that case we ignore the main commit msg for the old
2015- * funding tx, and for the splice candidates that didnt win. But we must
2016- * listen to the one that is for the winning splice candidate */
2019+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2020+ * - If `funding_txid` is missing in one of the `commitment_signed` messages:
2021+ * - MUST send an `error` and fail the channel.
2022+ */
2023+ if (commit_index && !cs_tlv -> splice_info )
2024+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2025+ "Must send funding_txid when sending"
2026+ " a commitment batch" );
20172027
20182028 if (!changed_htlcs ) {
20192029 changed_htlcs = tal_arr (msg , const struct htlc * , 0 );
@@ -2108,7 +2118,6 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21082118 "Bad commit_sig signature %" PRIu64 " %s for tx"
21092119 " %s wscript %s key %s feerate %u. Outpoint"
21102120 " %s, funding_sats: %s, splice_info: %s,"
2111- " race_await_commit: %s,"
21122121 " inflight splice count: %zu" ,
21132122 local_index ,
21142123 fmt_bitcoin_signature (msg , & commit_sig ),
@@ -2122,8 +2131,6 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21222131 ? fmt_bitcoin_txid (tmpctx ,
21232132 cs_tlv -> splice_info )
21242133 : "N/A" ,
2125- peer -> splice_state -> await_commitment_succcess ? "yes"
2126- : "no" ,
21272134 tal_count (peer -> splice_state -> inflights ));
21282135 }
21292136
@@ -2224,9 +2231,14 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
22242231 tal_count (peer -> splice_state -> inflights ));
22252232
22262233 commitsigs = tal_arr (NULL , const struct commitsig * , 0 );
2227- /* We expect multiple consequtive commit_sig messages if we have
2228- * inflight splices. Since consequtive is requred, we recurse for
2229- * each expected message, blocking until all are received. */
2234+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2235+ * - If there are pending splice transactions:
2236+ * - MUST validate each `commitment_signed` based on `funding_txid`.
2237+ * - If `commitment_signed` is missing for a funding transaction:
2238+ * - MUST send an `error` and fail the channel.
2239+ * - Otherwise:
2240+ * - MUST respond with a `revoke_and_ack` message.
2241+ */
22302242 for (i = 0 ; i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
22312243 s64 funding_diff = sats_diff (peer -> splice_state -> inflights [i ]-> amnt ,
22322244 peer -> channel -> funding_sats );
@@ -2317,7 +2329,6 @@ static int commit_cmp(const void *a, const void *n, void *peer)
23172329
23182330static struct commitsig_info * handle_peer_commit_sig_batch (struct peer * peer ,
23192331 const u8 * msg ,
2320- u32 commit_index ,
23212332 struct pubkey remote_funding ,
23222333 const struct htlc * * changed_htlcs ,
23232334 s64 splice_amnt ,
@@ -2347,6 +2358,16 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23472358 peer_failed_warn (peer -> pps , & peer -> channel_id ,
23482359 "Bad commit_sig %s" , tal_hex (msg , msg ));
23492360
2361+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2362+ * - If there are pending splice transactions and the sending node did not
2363+ * send `start_batch` followed by a batch of `commitment_signed` messages:
2364+ * - MUST send an `error` and fail the channel.
2365+ */
2366+ if (batch_size < 2 && last_inflight (peer ))
2367+ peer_failed_err (peer -> pps , & peer -> channel_id , "Must send a"
2368+ " commitment batch (ie. start_batch) when I"
2369+ " have pending splices inflight." );
2370+
23502371 msg_batch = tal_arr (tmpctx , const u8 * , batch_size );
23512372 msg_batch [0 ] = msg ;
23522373
@@ -2383,9 +2404,16 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23832404 msg_batch [i ] = sub_msg ;
23842405 }
23852406
2407+ /* BOLT-f9fd539db6cc6f3e532fdc8cc1ebe8eb1a8fd717
2408+ * - Otherwise (no pending splice transactions):
2409+ * - MUST ignore `commitment_signed` where `funding_txid` does not match
2410+ * the current funding transaction.
2411+ */
2412+ /* Sort puts all unrecognized `commitment_signed` messages onto the back
2413+ * of `msg_batch`, where they will be ignored */
23862414 asort (msg_batch , tal_count (msg_batch ), commit_cmp , peer );
23872415
2388- return handle_peer_commit_sig (peer , msg_batch [0 ], commit_index ,
2416+ return handle_peer_commit_sig (peer , msg_batch [0 ], 0 ,
23892417 remote_funding , changed_htlcs ,
23902418 splice_amnt , remote_splice_amnt ,
23912419 local_index , local_per_commit ,
@@ -2411,7 +2439,7 @@ static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
24112439 return ;
24122440 }
24132441
2414- handle_peer_commit_sig_batch (peer , peer_read (tmpctx , peer -> pps ), 0 ,
2442+ handle_peer_commit_sig_batch (peer , peer_read (tmpctx , peer -> pps ),
24152443 peer -> channel -> funding_pubkey [REMOTE ],
24162444 NULL , 0 , 0 ,
24172445 peer -> next_index [LOCAL ],
@@ -2560,8 +2588,6 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
25602588 fmt_pubkey (tmpctx , & peer -> remote_per_commit ),
25612589 fmt_pubkey (tmpctx , & peer -> old_remote_per_commit ));
25622590
2563- peer -> splice_state -> await_commitment_succcess = false;
2564-
25652591 /* STFU can't be activated during pending updates.
25662592 * With updates finish let's handle a potentially queued stfu request.
25672593 */
@@ -4078,8 +4104,6 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
40784104 peer -> splicing -> remote_funding_pubkey = last_inflight (peer )-> remote_funding ;
40794105 }
40804106
4081- peer -> splice_state -> await_commitment_succcess = false;
4082-
40834107 if (!is_stfu_active (peer ))
40844108 peer_failed_warn (peer -> pps , & peer -> channel_id ,
40854109 "Must be in STFU mode before intiating splice" );
@@ -4765,7 +4789,6 @@ static void handle_splice_stfu_success(struct peer *peer)
47654789 init_rbf_tlvs );
47664790 }
47674791
4768- peer -> splice_state -> await_commitment_succcess = false;
47694792 peer_write (peer -> pps , take (msg ));
47704793}
47714794
@@ -4983,7 +5006,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
49835006 handle_peer_start_batch (peer , msg );
49845007 return ;
49855008 case WIRE_COMMITMENT_SIGNED :
4986- handle_peer_commit_sig_batch (peer , msg , 0 ,
5009+ handle_peer_commit_sig_batch (peer , msg ,
49875010 peer -> channel -> funding_pubkey [REMOTE ],
49885011 NULL , 0 , 0 ,
49895012 peer -> next_index [LOCAL ],
0 commit comments