@@ -119,8 +119,6 @@ pub use bitcoin;
119119use bitcoin:: secp256k1:: PublicKey ;
120120#[ cfg( feature = "uniffi" ) ]
121121pub use bitcoin:: FeeRate ;
122- #[ cfg( not( feature = "uniffi" ) ) ]
123- use bitcoin:: FeeRate ;
124122use bitcoin:: { Address , Amount , BlockHash , Network } ;
125123#[ cfg( feature = "uniffi" ) ]
126124pub use builder:: ArcedNodeBuilder as Builder ;
@@ -138,7 +136,9 @@ pub use error::Error as NodeError;
138136use error:: Error ;
139137pub use event:: Event ;
140138use event:: { EventHandler , EventQueue } ;
141- use fee_estimator:: { ConfirmationTarget , FeeEstimator , OnchainFeeEstimator } ;
139+ use fee_estimator:: {
140+ max_funding_feerate, rbf_splice_feerates, ConfirmationTarget , FeeEstimator , OnchainFeeEstimator ,
141+ } ;
142142#[ cfg( feature = "uniffi" ) ]
143143use ffi:: * ;
144144use gossip:: GossipSource ;
@@ -1578,7 +1578,7 @@ impl Node {
15781578 {
15791579 let min_feerate =
15801580 self . fee_estimator . estimate_fee_rate ( ConfirmationTarget :: ChannelFunding ) ;
1581- let max_feerate = FeeRate :: from_sat_per_kwu ( min_feerate. to_sat_per_kwu ( ) * 3 / 2 ) ;
1581+ let max_feerate = max_funding_feerate ( min_feerate) ;
15821582
15831583 let splice_amount_sats = match splice_amount_sats {
15841584 FundingAmount :: Exact { amount_sats } => amount_sats,
@@ -1767,7 +1767,7 @@ impl Node {
17671767
17681768 let min_feerate =
17691769 self . fee_estimator . estimate_fee_rate ( ConfirmationTarget :: ChannelFunding ) ;
1770- let max_feerate = FeeRate :: from_sat_per_kwu ( min_feerate. to_sat_per_kwu ( ) * 3 / 2 ) ;
1770+ let max_feerate = max_funding_feerate ( min_feerate) ;
17711771
17721772 let funding_template = self
17731773 . channel_manager
@@ -2407,44 +2407,12 @@ pub(crate) fn new_channel_anchor_reserve_sats(
24072407 } )
24082408}
24092409
2410- /// The most we are willing to pay for a channel funding transaction: `1.5x` our funding feerate
2411- /// estimate. Used as the `max_feerate` ceiling for splices and their RBF fee bumps.
2412- fn max_funding_feerate ( estimate : FeeRate ) -> FeeRate {
2413- FeeRate :: from_sat_per_kwu ( estimate. to_sat_per_kwu ( ) * 3 / 2 )
2414- }
2415-
2416- /// Picks the `(target, max)` feerates for replacing a pending splice's in-flight funding
2417- /// transaction via RBF, or `None` if the RBF can't be done within our fee ceiling.
2418- ///
2419- /// `max` is the most we are willing to pay (see [`max_funding_feerate`]), which tracks our current
2420- /// estimate and so may have risen or fallen since the original splice; it is never inflated to meet
2421- /// the RBF minimum. `target` is what we actually pay — our current estimate, or the template's RBF
2422- /// minimum if that is higher (required to replace the transaction). If that minimum exceeds `max`,
2423- /// we can't RBF.
2424- fn rbf_splice_feerates ( estimate : FeeRate , min_rbf_feerate : FeeRate ) -> Option < ( FeeRate , FeeRate ) > {
2425- let max = max_funding_feerate ( estimate) ;
2426- let target = estimate. max ( min_rbf_feerate) ;
2427- ( target <= max) . then_some ( ( target, max) )
2428- }
2429-
24302410#[ cfg( test) ]
24312411mod tests {
24322412 use lightning:: util:: ser:: { Readable , Writeable } ;
24332413
24342414 use super :: * ;
24352415
2436- #[ test]
2437- fn rbf_splice_feerates_target_and_max ( ) {
2438- let kwu = FeeRate :: from_sat_per_kwu;
2439- // Estimate below the RBF minimum but within our ceiling: pay the minimum to replace the
2440- // transaction; the max stays 1.5x the estimate (never inflated) and already clears it.
2441- assert_eq ! ( rbf_splice_feerates( kwu( 253 ) , kwu( 278 ) ) , Some ( ( kwu( 278 ) , kwu( 253 * 3 / 2 ) ) ) ) ;
2442- // Estimate risen above the RBF minimum: pay the higher estimate, not the stale minimum.
2443- assert_eq ! ( rbf_splice_feerates( kwu( 500 ) , kwu( 278 ) ) , Some ( ( kwu( 500 ) , kwu( 500 * 3 / 2 ) ) ) ) ;
2444- // RBF minimum above our max (1.5x a fallen estimate): we can't RBF within our ceiling.
2445- assert_eq ! ( rbf_splice_feerates( kwu( 100 ) , kwu( 278 ) ) , None ) ;
2446- }
2447-
24482416 #[ test]
24492417 fn node_metrics_reads_legacy_rgs_snapshot_timestamp ( ) {
24502418 // Pre-#615, `NodeMetrics` persisted `latest_rgs_snapshot_timestamp` as an optional
0 commit comments