Skip to content

Commit 5462ab2

Browse files
committed
Check that funder covers the fee spike buffer multiple after a splice
We do this for HTLCs, so we should also do this for splices. This applies to `only_static_remote_key` channels alone.
1 parent 0ea2616 commit 5462ab2

5 files changed

Lines changed: 330 additions & 38 deletions

File tree

lightning-tests/src/upgrade_downgrade_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ fn do_test_0_1_htlc_forward_after_splice(fail_htlc: bool) {
457457
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
458458
}];
459459
let channel_id = ChannelId(chan_id_bytes_a);
460-
let funding_contribution = initiate_splice_out(&nodes[0], &nodes[1], channel_id, outputs);
460+
let funding_contribution =
461+
initiate_splice_out(&nodes[0], &nodes[1], channel_id, outputs).unwrap();
461462
let (splice_tx, _) = splice_channel(&nodes[0], &nodes[1], channel_id, funding_contribution);
462463
for node in nodes.iter() {
463464
mine_transaction(node, &splice_tx);

lightning/src/ln/async_signer_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ fn test_async_splice_initial_commit_sig() {
15761576
value: Amount::from_sat(1_000),
15771577
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
15781578
}];
1579-
let contribution = initiate_splice_out(initiator, acceptor, channel_id, outputs);
1579+
let contribution = initiate_splice_out(initiator, acceptor, channel_id, outputs).unwrap();
15801580
negotiate_splice_tx(initiator, acceptor, channel_id, contribution);
15811581

15821582
assert!(initiator.node.get_and_clear_pending_msg_events().is_empty());

lightning/src/ln/channel.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5469,6 +5469,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {
54695469
} else {
54705470
1
54715471
};
5472+
// Note that the feerate is 0 in zero-fee commitment channels, so this statement is a noop
54725473
let spiked_feerate = feerate * fee_spike_multiple;
54735474
let (remote_stats, _remote_htlcs) = self
54745475
.get_next_remote_commitment_stats(
@@ -12401,14 +12402,23 @@ where
1240112402
// We are not interested in dust exposure
1240212403
let dust_exposure_limiting_feerate = None;
1240312404

12405+
// Note that the feerate is 0 in zero-fee commitment channels, so this statement is a noop
12406+
let feerate_per_kw = if !funding.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
12407+
// Similar to HTLC additions, require the funder to have enough funds reserved for
12408+
// fees such that the feerate can jump without rendering the channel useless.
12409+
self.context.feerate_per_kw * FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE as u32
12410+
} else {
12411+
self.context.feerate_per_kw
12412+
};
12413+
1240412414
let (local_stats, _local_htlcs) = self
1240512415
.context
1240612416
.get_next_local_commitment_stats(
1240712417
funding,
1240812418
None, // htlc_candidate
1240912419
include_counterparty_unknown_htlcs,
1241012420
addl_nondust_htlc_count,
12411-
self.context.feerate_per_kw,
12421+
feerate_per_kw,
1241212422
dust_exposure_limiting_feerate,
1241312423
)
1241412424
.map_err(|()| "Balance exhausted on local commitment")?;
@@ -12420,7 +12430,7 @@ where
1242012430
None, // htlc_candidate
1242112431
include_counterparty_unknown_htlcs,
1242212432
addl_nondust_htlc_count,
12423-
self.context.feerate_per_kw,
12433+
feerate_per_kw,
1242412434
dust_exposure_limiting_feerate,
1242512435
)
1242612436
.map_err(|()| "Balance exhausted on remote commitment")?;

0 commit comments

Comments
 (0)