@@ -76,13 +76,16 @@ struct peer {
7676 /* What (additional) messages the HSM accepts */
7777 u32 * hsm_capabilities ;
7878
79+ /* The feerate to initiate a splice */
80+ u32 feerate_splice ;
81+
7982 /* Tolerable amounts for feerate (only relevant for fundee). */
8083 u32 feerate_min , feerate_max ;
8184
8285 /* Feerate to be used when creating penalty transactions. */
8386 u32 feerate_penalty ;
8487
85- /* Feerate to be used when opening (or splicing) a channel. */
88+ /* Feerate to be used when opening a channel. */
8689 u32 feerate_opening ;
8790
8891 /* Local next per-commit point. */
@@ -1894,9 +1897,9 @@ static void check_tx_abort(struct peer *peer, const u8 *msg, struct bitcoin_txid
18941897 exit (0 );
18951898}
18961899
1897- static void splice_abort (struct peer * peer , const char * fmt , ...)
1900+ static void splice_abort (struct peer * peer , struct inflight * inflight ,
1901+ const char * fmt , ...)
18981902{
1899- struct inflight * inflight = last_inflight (peer );
19001903 struct bitcoin_outpoint * outpoint ;
19011904 u8 * msg ;
19021905 char * reason ;
@@ -3337,7 +3340,8 @@ static struct amount_sat calc_balance(struct peer *peer)
33373340}
33383341
33393342/* Returns the total channel funding output amount if all checks pass.
3340- * Otherwise, exits via peer_failed_warn. */
3343+ * Otherwise, exits via peer_failed_warn.
3344+ * Note: Should only be called before adding splice to inflights. */
33413345static struct amount_sat check_balances (struct peer * peer ,
33423346 enum tx_role our_role ,
33433347 const struct wally_psbt * psbt ,
@@ -3388,15 +3392,15 @@ static struct amount_sat check_balances(struct peer *peer,
33883392 * additional funds are otherwise contributed. */
33893393 if (!amount_msat_can_add_sat_s64 (in [TX_INITIATOR ],
33903394 peer -> splicing -> opener_relative )) {
3391- splice_abort (peer , "Intiator is attempting to splice out"
3395+ splice_abort (peer , NULL , "Intiator is attempting to splice out"
33923396 " %" PRId64 "sat funds out of channel while only "
33933397 "having %s funds attributable to them." ,
33943398 peer -> splicing -> opener_relative ,
33953399 fmt_amount_m_as_sat (tmpctx , in [TX_INITIATOR ]));
33963400 }
33973401 if (!amount_msat_can_add_sat_s64 (in [TX_ACCEPTER ],
33983402 peer -> splicing -> accepter_relative )) {
3399- splice_abort (peer , "Accepter is attempting to splice out"
3403+ splice_abort (peer , NULL , "Accepter is attempting to splice out"
34003404 " %" PRId64 "sat funds out of channel while only "
34013405 "having %s funds attributable to them." ,
34023406 peer -> splicing -> accepter_relative ,
@@ -3452,7 +3456,7 @@ static struct amount_sat check_balances(struct peer *peer,
34523456 */
34533457 if (!amount_msat_add_sat_s64 (& funding_amount , funding_amount ,
34543458 peer -> splicing -> opener_relative ))
3455- splice_abort (peer , "Splice initiator did not provide enough"
3459+ splice_abort (peer , NULL , "Splice initiator did not provide enough"
34563460 " funding, funding_amount: %s, opener_relative:"
34573461 " %" PRIu64 ,
34583462 fmt_amount_msat (tmpctx , funding_amount ),
@@ -3469,7 +3473,7 @@ static struct amount_sat check_balances(struct peer *peer,
34693473
34703474 if (!amount_msat_add_sat_s64 (& funding_amount , funding_amount ,
34713475 peer -> splicing -> accepter_relative ))
3472- splice_abort (peer , "Splice accepter did not provide enough"
3476+ splice_abort (peer , NULL , "Splice accepter did not provide enough"
34733477 " funding" );
34743478 if (!amount_msat_add_sat_s64 (& out [TX_ACCEPTER ], out [TX_ACCEPTER ],
34753479 peer -> splicing -> accepter_relative ))
@@ -3486,7 +3490,7 @@ static struct amount_sat check_balances(struct peer *peer,
34863490 out [TX_INITIATOR ],
34873491 true);
34883492 wire_sync_write (MASTER_FD , take (msg ));
3489- splice_abort (peer ,
3493+ splice_abort (peer , NULL ,
34903494 "Initiator funding is less than commited"
34913495 " amount. Initiator contributing %s but they"
34923496 " committed to %s. Pending offered HTLC"
@@ -3513,7 +3517,7 @@ static struct amount_sat check_balances(struct peer *peer,
35133517 out [TX_INITIATOR ],
35143518 true);
35153519 wire_sync_write (MASTER_FD , take (msg ));
3516- splice_abort (peer ,
3520+ splice_abort (peer , NULL ,
35173521 "Accepter funding is less than commited"
35183522 " amount. Accepter contributing %s but they"
35193523 " committed to %s. Pending offered HTLC"
@@ -3543,10 +3547,10 @@ static struct amount_sat check_balances(struct peer *peer,
35433547 calc_weight (TX_INITIATOR , psbt , opener ));
35443548
35453549 if (opener ) {
3546- status_debug ("User specified fee of %s. Opening feerate %" PRIu32
3550+ status_debug ("User specified fee of %s. Splice feerate %" PRIu32
35473551 " * weight %lu / 1000 = %s" ,
35483552 fmt_amount_m_as_sat (tmpctx , initiator_fee ),
3549- peer -> feerate_opening ,
3553+ peer -> feerate_splice ,
35503554 calc_weight (TX_INITIATOR , psbt , false),
35513555 fmt_amount_sat (tmpctx , max_initiator_fee ));
35523556 }
@@ -3556,7 +3560,7 @@ static struct amount_sat check_balances(struct peer *peer,
35563560 msg = towire_channeld_splice_feerate_error (NULL , initiator_fee ,
35573561 false);
35583562 wire_sync_write (MASTER_FD , take (msg ));
3559- splice_abort (peer ,
3563+ splice_abort (peer , NULL ,
35603564 "%s fee (%s) was too low, must be at least %s" ,
35613565 opener ? "Our" : "Your" ,
35623566 fmt_amount_msat (tmpctx , initiator_fee ),
@@ -3576,7 +3580,7 @@ static struct amount_sat check_balances(struct peer *peer,
35763580
35773581 wire_sync_write (MASTER_FD , take (msg ));
35783582
3579- splice_abort (peer ,
3583+ splice_abort (peer , NULL ,
35803584 "Our own fee (%s) is too high to use without"
35813585 " forcing. Opening feerate %" PRIu32
35823586 " x weight %lu / 1000 = %s (max)" ,
@@ -3590,7 +3594,7 @@ static struct amount_sat check_balances(struct peer *peer,
35903594 msg = towire_channeld_splice_feerate_error (NULL , accepter_fee ,
35913595 false);
35923596 wire_sync_write (MASTER_FD , take (msg ));
3593- splice_abort (peer ,
3597+ splice_abort (peer , NULL ,
35943598 "%s fee (%s) was too low, must be at least %s"
35953599 " weight: %" PRIu64 ", feerate_max: %" PRIu32 ,
35963600 opener ? "Your" : "Our" ,
@@ -3604,7 +3608,7 @@ static struct amount_sat check_balances(struct peer *peer,
36043608 msg = towire_channeld_splice_feerate_error (NULL , accepter_fee ,
36053609 true);
36063610 wire_sync_write (MASTER_FD , take (msg ));
3607- splice_abort (peer ,
3611+ splice_abort (peer , NULL ,
36083612 "Our own fee (%s) was too high, max without"
36093613 " forcing is %s." ,
36103614 fmt_amount_msat (tmpctx , accepter_fee ),
@@ -5027,7 +5031,7 @@ static void handle_abort_req(struct peer *peer, const u8 *inmsg)
50275031 if (!fromwire_channeld_abort (inmsg ))
50285032 master_badmsg (WIRE_CHANNELD_ABORT , inmsg );
50295033
5030- splice_abort (peer , "requested by user" );
5034+ splice_abort (peer , last_inflight ( peer ), "requested by user" );
50315035}
50325036
50335037static void peer_in (struct peer * peer , const u8 * msg )
@@ -5883,7 +5887,8 @@ static void peer_reconnect(struct peer *peer,
58835887 " channel, ignoring it: %s" ,
58845888 fmt_bitcoin_outpoint (tmpctx , & peer -> channel -> funding ));
58855889 else
5886- splice_abort (peer , "next_funding_txid not recognized." );
5890+ splice_abort (peer , NULL ,
5891+ "next_funding_txid not recognized." );
58875892 }
58885893
58895894 /* BOLT #2:
@@ -6377,11 +6382,13 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg)
63776382{
63786383 u32 feerate ;
63796384
6380- if (!fromwire_channeld_feerates (inmsg , & feerate ,
6381- & peer -> feerate_min ,
6382- & peer -> feerate_max ,
6383- & peer -> feerate_penalty ,
6384- & peer -> feerate_opening ))
6385+ if (!fromwire_channeld_feerates (inmsg ,
6386+ & feerate ,
6387+ & peer -> feerate_min ,
6388+ & peer -> feerate_max ,
6389+ & peer -> feerate_penalty ,
6390+ & peer -> feerate_opening ,
6391+ & peer -> feerate_splice ))
63856392 master_badmsg (WIRE_CHANNELD_FEERATES , inmsg );
63866393
63876394 /* BOLT #2:
@@ -6749,6 +6756,7 @@ static void init_channel(struct peer *peer)
67496756 & lease_expiry ,
67506757 & conf [LOCAL ], & conf [REMOTE ],
67516758 & fee_states ,
6759+ & peer -> feerate_splice ,
67526760 & peer -> feerate_min ,
67536761 & peer -> feerate_max ,
67546762 & peer -> feerate_penalty ,
0 commit comments