Skip to content

Commit 9ce9405

Browse files
jkczyzclaude
andcommitted
Use floor division for the spec's 25/24 RBF feerate rule
The spec says the 25/24 multiplicative feerate is "rounded down", but min_rbf_feerate used ceiling division. This made the computed minimum 1 sat/kwu too high when prev * 25 is not evenly divisible by 24, which could reject valid counterparty feerates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 425aff8 commit 9ce9405

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6777,7 +6777,7 @@ fn get_v2_channel_reserve_satoshis(
67776777
/// multiplicative 25/24 rule alone would be insufficient.
67786778
fn min_rbf_feerate(prev_feerate: u32) -> FeeRate {
67796779
let flat_increment = (prev_feerate as u64).saturating_add(25);
6780-
let spec_increment = ((prev_feerate as u64) * 25).div_ceil(24);
6780+
let spec_increment = (prev_feerate as u64) * 25 / 24;
67816781
FeeRate::from_sat_per_kwu(cmp::max(flat_increment, spec_increment))
67826782
}
67836783

lightning/src/ln/splicing_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4674,7 +4674,7 @@ fn test_splice_rbf_insufficient_feerate_high() {
46744674
expect_splice_pending_event(&nodes[0], &node_id_1);
46754675
expect_splice_pending_event(&nodes[1], &node_id_0);
46764676

4677-
// prev=1000: flat increment gives 1000+25=1025, 25/24 rule gives ceil(1000*25/24)=1042.
4677+
// prev=1000: flat increment gives 1000+25=1025, 25/24 rule gives 1000*25/24=1041.
46784678
// Feerate 1025 satisfies the flat increment but not 25/24 — rejected.
46794679
reenter_quiescence(&nodes[0], &nodes[1], &channel_id);
46804680

@@ -4689,13 +4689,13 @@ fn test_splice_rbf_insufficient_feerate_high() {
46894689
let tx_abort = get_event_msg!(nodes[1], MessageSendEvent::SendTxAbort, node_id_0);
46904690
assert_eq!(tx_abort.channel_id, channel_id);
46914691

4692-
// Feerate 1042 satisfies both rules — accepted.
4692+
// Feerate 1041 satisfies both rules — accepted.
46934693
nodes[0].node.handle_tx_abort(node_id_1, &tx_abort);
46944694

46954695
let tx_init_rbf = msgs::TxInitRbf {
46964696
channel_id,
46974697
locktime: 0,
4698-
feerate_sat_per_1000_weight: 1042,
4698+
feerate_sat_per_1000_weight: 1041,
46994699
funding_output_contribution: Some(added_value.to_sat() as i64),
47004700
};
47014701

0 commit comments

Comments
 (0)