@@ -2010,30 +2010,33 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20102010 htlc_sigs = unraw_sigs (tmpctx , raw_sigs ,
20112011 channel_has_anchors (peer -> channel ));
20122012
2013- if (commit_index ) {
2013+ // - If `batch` is smaller than or equal to `1`:
2014+ // - MUST send an `error` and fail the channel.
2015+ if (cs_tlv && cs_tlv -> splice_info && cs_tlv -> splice_info -> batch_size <= 1 )
2016+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2017+ "Must only set batch tlv for batches greater than 1" );
2018+
2019+ if (commit_index > 0 ) {
20142020 outpoint = peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint ;
20152021 funding_sats = peer -> splice_state -> inflights [commit_index - 1 ]-> amnt ;
2022+ }
2023+ else {
2024+ outpoint = peer -> channel -> funding ;
2025+ funding_sats = peer -> channel -> funding_sats ;
2026+ }
20162027
2017- if (!cs_tlv || !cs_tlv -> splice_info )
2018- peer_failed_err (peer -> pps , & peer -> channel_id ,
2019- "Must set funding_txid for each"
2020- " extra commitment_signed message." );
2021-
2022- status_info ("handle_peer_commit_sig for inflight outpoint %s" , fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint .txid ));
2028+ if (cs_tlv && cs_tlv -> splice_info ) {
2029+ status_info ("handle_peer_commit_sig for outpoint %s" , fmt_bitcoin_txid (tmpctx , & outpoint .txid ));
20232030 status_info ("handle_peer_commit_sig cs_tlv->splice_info->funding_txid %s" , fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
20242031
2025- if (!bitcoin_txid_eq (& peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ,
2026- & cs_tlv -> splice_info -> funding_txid ))
2032+ if (!bitcoin_txid_eq (& outpoint .txid ,
2033+ & cs_tlv -> splice_info -> funding_txid ))
20272034 peer_failed_err (peer -> pps , & peer -> channel_id ,
20282035 "Expected commit sig message for %s but"
20292036 " got %s" ,
2030- fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ),
2037+ fmt_bitcoin_txid (tmpctx , & outpoint .txid ),
20312038 fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
20322039 }
2033- else {
2034- outpoint = peer -> channel -> funding ;
2035- funding_sats = peer -> channel -> funding_sats ;
2036- }
20372040
20382041 txs = channel_txs (tmpctx , & outpoint , funding_sats , & htlc_map ,
20392042 NULL , & funding_wscript , peer -> channel ,
@@ -2177,7 +2180,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21772180 result -> old_secret = old_secret ;
21782181 /* Only the parent call continues from here.
21792182 * Return for all child calls. */
2180- if (commit_index )
2183+ if (batch_index > 0 )
21812184 return result ;
21822185
21832186 if (tal_count (msg_batch ) - 1 < tal_count (peer -> splice_state -> inflights ))
@@ -2203,7 +2206,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
22032206 changed_htlcs , sub_splice_amnt ,
22042207 funding_diff - sub_splice_amnt ,
22052208 local_index , local_per_commit ,
2206- allow_empty_commit , NULL );
2209+ allow_empty_commit , msg_batch );
22072210 old_secret = result -> old_secret ;
22082211 tal_arr_expand (& commitsigs , result -> commitsig );
22092212 tal_steal (commitsigs , result );
@@ -2367,7 +2370,7 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23672370 status_debug ("Sorting the msg_batch of tal_count %d, batch_size: %d" , (int )tal_count (msg_batch ), (int )batch_size );
23682371 asort (msg_batch , tal_count (msg_batch ), commit_cmp , peer );
23692372
2370- return handle_peer_commit_sig (peer , msg , commit_index , remote_funding ,
2373+ return handle_peer_commit_sig (peer , msg_batch [ 0 ] , commit_index , remote_funding ,
23712374 changed_htlcs , splice_amnt ,
23722375 remote_splice_amnt , local_index ,
23732376 local_per_commit , allow_empty_commit ,
@@ -5399,7 +5402,7 @@ static void peer_reconnect(struct peer *peer,
53995402#endif
54005403
54015404 inflight = last_inflight (peer );
5402-
5405+
54035406 if (feature_negotiated (peer -> our_features , peer -> their_features , OPT_SPLICE )) {
54045407 /* Subtle: we free tmpctx below as we loop, so tal off peer */
54055408 send_tlvs = tlv_channel_reestablish_tlvs_new (peer );
@@ -5411,12 +5414,12 @@ static void peer_reconnect(struct peer *peer,
54115414 */
54125415 if (peer -> splice_state -> locked_ready [REMOTE ] && peer -> splice_state -> remote_locked_txid != NULL ) {
54135416 send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , peer -> splice_state -> remote_locked_txid );
5414- }
5417+ }
54155418 else {
54165419 send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , & peer -> channel -> funding .txid );
54175420 }
54185421
5419- /*
5422+ /*
54205423 * my_current_funding_locked tlv:
54215424 * - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
54225425 * - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
0 commit comments