@@ -431,8 +431,6 @@ static void check_mutual_splice_locked(struct peer *peer)
431
431
fmt_bitcoin_txid (tmpctx ,
432
432
& peer -> splice_state -> locked_txid ));
433
433
434
- peer -> splice_state -> await_commitment_succcess = true;
435
-
436
434
/* This splice_locked event is used, so reset the flags to false */
437
435
peer -> splice_state -> locked_ready [LOCAL ] = false;
438
436
peer -> splice_state -> locked_ready [REMOTE ] = false;
@@ -1670,8 +1668,6 @@ static void send_revocation(struct peer *peer,
1670
1668
master_wait_sync_reply (tmpctx , peer , take (msg_for_master ),
1671
1669
WIRE_CHANNELD_GOT_COMMITSIG_REPLY );
1672
1670
1673
- peer -> splice_state -> await_commitment_succcess = false;
1674
-
1675
1671
/* Now that the master has persisted the new commitment advance the HSMD
1676
1672
* and fetch the revocation secret for the old one. */
1677
1673
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,
1990
1986
peer_failed_warn (peer -> pps , & peer -> channel_id ,
1991
1987
"Bad commit_sig %s" , tal_hex (msg , msg ));
1992
1988
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 ));
2011
2017
}
2012
2018
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" );
2017
2027
2018
2028
if (!changed_htlcs ) {
2019
2029
changed_htlcs = tal_arr (msg , const struct htlc * , 0 );
@@ -2108,7 +2118,6 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2108
2118
"Bad commit_sig signature %" PRIu64 " %s for tx"
2109
2119
" %s wscript %s key %s feerate %u. Outpoint"
2110
2120
" %s, funding_sats: %s, splice_info: %s,"
2111
- " race_await_commit: %s,"
2112
2121
" inflight splice count: %zu" ,
2113
2122
local_index ,
2114
2123
fmt_bitcoin_signature (msg , & commit_sig ),
@@ -2122,8 +2131,6 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2122
2131
? fmt_bitcoin_txid (tmpctx ,
2123
2132
cs_tlv -> splice_info )
2124
2133
: "N/A" ,
2125
- peer -> splice_state -> await_commitment_succcess ? "yes"
2126
- : "no" ,
2127
2134
tal_count (peer -> splice_state -> inflights ));
2128
2135
}
2129
2136
@@ -2224,9 +2231,14 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2224
2231
tal_count (peer -> splice_state -> inflights ));
2225
2232
2226
2233
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
+ */
2230
2242
for (i = 0 ; i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
2231
2243
s64 funding_diff = sats_diff (peer -> splice_state -> inflights [i ]-> amnt ,
2232
2244
peer -> channel -> funding_sats );
@@ -2317,7 +2329,6 @@ static int commit_cmp(const void *a, const void *n, void *peer)
2317
2329
2318
2330
static struct commitsig_info * handle_peer_commit_sig_batch (struct peer * peer ,
2319
2331
const u8 * msg ,
2320
- u32 commit_index ,
2321
2332
struct pubkey remote_funding ,
2322
2333
const struct htlc * * changed_htlcs ,
2323
2334
s64 splice_amnt ,
@@ -2347,6 +2358,16 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2347
2358
peer_failed_warn (peer -> pps , & peer -> channel_id ,
2348
2359
"Bad commit_sig %s" , tal_hex (msg , msg ));
2349
2360
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
+
2350
2371
msg_batch = tal_arr (tmpctx , const u8 * , batch_size );
2351
2372
msg_batch [0 ] = msg ;
2352
2373
@@ -2383,10 +2404,17 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2383
2404
msg_batch [i ] = sub_msg ;
2384
2405
}
2385
2406
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 */
2386
2414
status_debug ("Sorting the msg_batch of tal_count %d, batch_size: %d" , (int )tal_count (msg_batch ), (int )batch_size );
2387
2415
asort (msg_batch , tal_count (msg_batch ), commit_cmp , peer );
2388
2416
2389
- return handle_peer_commit_sig (peer , msg_batch [0 ], commit_index ,
2417
+ return handle_peer_commit_sig (peer , msg_batch [0 ], 0 ,
2390
2418
remote_funding , changed_htlcs ,
2391
2419
splice_amnt , remote_splice_amnt ,
2392
2420
local_index , local_per_commit ,
@@ -2412,7 +2440,7 @@ static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
2412
2440
return ;
2413
2441
}
2414
2442
2415
- handle_peer_commit_sig_batch (peer , peer_read (tmpctx , peer -> pps ), 0 ,
2443
+ handle_peer_commit_sig_batch (peer , peer_read (tmpctx , peer -> pps ),
2416
2444
peer -> channel -> funding_pubkey [REMOTE ],
2417
2445
NULL , 0 , 0 ,
2418
2446
peer -> next_index [LOCAL ],
@@ -2561,8 +2589,6 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
2561
2589
fmt_pubkey (tmpctx , & peer -> remote_per_commit ),
2562
2590
fmt_pubkey (tmpctx , & peer -> old_remote_per_commit ));
2563
2591
2564
- peer -> splice_state -> await_commitment_succcess = false;
2565
-
2566
2592
/* STFU can't be activated during pending updates.
2567
2593
* With updates finish let's handle a potentially queued stfu request.
2568
2594
*/
@@ -4079,8 +4105,6 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
4079
4105
peer -> splicing -> remote_funding_pubkey = last_inflight (peer )-> remote_funding ;
4080
4106
}
4081
4107
4082
- peer -> splice_state -> await_commitment_succcess = false;
4083
-
4084
4108
if (!is_stfu_active (peer ))
4085
4109
peer_failed_warn (peer -> pps , & peer -> channel_id ,
4086
4110
"Must be in STFU mode before intiating splice" );
@@ -4766,7 +4790,6 @@ static void handle_splice_stfu_success(struct peer *peer)
4766
4790
init_rbf_tlvs );
4767
4791
}
4768
4792
4769
- peer -> splice_state -> await_commitment_succcess = false;
4770
4793
peer_write (peer -> pps , take (msg ));
4771
4794
}
4772
4795
@@ -4984,7 +5007,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
4984
5007
handle_peer_start_batch (peer , msg );
4985
5008
return ;
4986
5009
case WIRE_COMMITMENT_SIGNED :
4987
- handle_peer_commit_sig_batch (peer , msg , 0 ,
5010
+ handle_peer_commit_sig_batch (peer , msg ,
4988
5011
peer -> channel -> funding_pubkey [REMOTE ],
4989
5012
NULL , 0 , 0 ,
4990
5013
peer -> next_index [LOCAL ],
0 commit comments