@@ -2012,30 +2012,33 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20122012 htlc_sigs = unraw_sigs (tmpctx , raw_sigs ,
20132013 channel_has_anchors (peer -> channel ));
20142014
2015- if (commit_index ) {
2015+ // - If `batch` is smaller than or equal to `1`:
2016+ // - MUST send an `error` and fail the channel.
2017+ if (cs_tlv && cs_tlv -> splice_info && cs_tlv -> splice_info -> batch_size <= 1 )
2018+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2019+ "Must only set batch tlv for batches greater than 1" );
2020+
2021+ if (commit_index > 0 ) {
20162022 outpoint = peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint ;
20172023 funding_sats = peer -> splice_state -> inflights [commit_index - 1 ]-> amnt ;
2024+ }
2025+ else {
2026+ outpoint = peer -> channel -> funding ;
2027+ funding_sats = peer -> channel -> funding_sats ;
2028+ }
20182029
2019- if (!cs_tlv || !cs_tlv -> splice_info )
2020- peer_failed_err (peer -> pps , & peer -> channel_id ,
2021- "Must set funding_txid for each"
2022- " extra commitment_signed message." );
2023-
2024- status_info ("handle_peer_commit_sig for inflight outpoint %s" , fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint .txid ));
2030+ if (cs_tlv && cs_tlv -> splice_info ) {
2031+ status_info ("handle_peer_commit_sig for outpoint %s" , fmt_bitcoin_txid (tmpctx , & outpoint .txid ));
20252032 status_info ("handle_peer_commit_sig cs_tlv->splice_info->funding_txid %s" , fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
20262033
2027- if (!bitcoin_txid_eq (& peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ,
2028- & cs_tlv -> splice_info -> funding_txid ))
2034+ if (!bitcoin_txid_eq (& outpoint .txid ,
2035+ & cs_tlv -> splice_info -> funding_txid ))
20292036 peer_failed_err (peer -> pps , & peer -> channel_id ,
20302037 "Expected commit sig message for %s but"
20312038 " got %s" ,
2032- fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ),
2039+ fmt_bitcoin_txid (tmpctx , & outpoint .txid ),
20332040 fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
20342041 }
2035- else {
2036- outpoint = peer -> channel -> funding ;
2037- funding_sats = peer -> channel -> funding_sats ;
2038- }
20392042
20402043 txs = channel_txs (tmpctx , & outpoint , funding_sats , & htlc_map ,
20412044 NULL , & funding_wscript , peer -> channel ,
@@ -2179,7 +2182,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21792182 result -> old_secret = old_secret ;
21802183 /* Only the parent call continues from here.
21812184 * Return for all child calls. */
2182- if (commit_index )
2185+ if (commit_index > 0 )
21832186 return result ;
21842187
21852188 if (tal_count (msg_batch ) - 1 < tal_count (peer -> splice_state -> inflights ))
@@ -2205,7 +2208,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
22052208 changed_htlcs , sub_splice_amnt ,
22062209 funding_diff - sub_splice_amnt ,
22072210 local_index , local_per_commit ,
2208- allow_empty_commit , NULL );
2211+ allow_empty_commit , msg_batch );
22092212 old_secret = result -> old_secret ;
22102213 tal_arr_expand (& commitsigs , result -> commitsig );
22112214 tal_steal (commitsigs , result );
@@ -2369,7 +2372,7 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23692372 status_debug ("Sorting the msg_batch of tal_count %d, batch_size: %d" , (int )tal_count (msg_batch ), (int )batch_size );
23702373 asort (msg_batch , tal_count (msg_batch ), commit_cmp , peer );
23712374
2372- return handle_peer_commit_sig (peer , msg , commit_index , remote_funding ,
2375+ return handle_peer_commit_sig (peer , msg_batch [ 0 ] , commit_index , remote_funding ,
23732376 changed_htlcs , splice_amnt ,
23742377 remote_splice_amnt , local_index ,
23752378 local_per_commit , allow_empty_commit ,
@@ -5401,7 +5404,7 @@ static void peer_reconnect(struct peer *peer,
54015404#endif
54025405
54035406 inflight = last_inflight (peer );
5404-
5407+
54055408 if (feature_negotiated (peer -> our_features , peer -> their_features , OPT_SPLICE )) {
54065409 /* Subtle: we free tmpctx below as we loop, so tal off peer */
54075410 send_tlvs = tlv_channel_reestablish_tlvs_new (peer );
@@ -5413,12 +5416,12 @@ static void peer_reconnect(struct peer *peer,
54135416 */
54145417 if (peer -> splice_state -> locked_ready [REMOTE ] && peer -> splice_state -> remote_locked_txid != NULL ) {
54155418 send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , peer -> splice_state -> remote_locked_txid );
5416- }
5419+ }
54175420 else {
54185421 send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , & peer -> channel -> funding .txid );
54195422 }
54205423
5421- /*
5424+ /*
54225425 * my_current_funding_locked tlv:
54235426 * - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
54245427 * - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
0 commit comments