@@ -40,7 +40,7 @@ use ln::chan_utils::{CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLC
4040use ln:: channelmanager:: HTLCSource ;
4141use chain;
4242use chain:: { BestBlock , WatchedOutput } ;
43- use chain:: chaininterface:: { BroadcasterInterface , FeeEstimator } ;
43+ use chain:: chaininterface:: { BroadcasterInterface , FeeEstimator , LowerBoundedFeeEstimator } ;
4444use chain:: transaction:: { OutPoint , TransactionData } ;
4545use chain:: keysinterface:: { SpendableOutputDescriptor , StaticPaymentOutputDescriptor , DelayedPaymentOutputDescriptor , Sign , KeysInterface } ;
4646use chain:: onchaintx:: OnchainTxHandler ;
@@ -1099,7 +1099,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
10991099 payment_hash : & PaymentHash ,
11001100 payment_preimage : & PaymentPreimage ,
11011101 broadcaster : & B ,
1102- fee_estimator : & F ,
1102+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
11031103 logger : & L ,
11041104 ) where
11051105 B :: Target : BroadcasterInterface ,
@@ -1129,7 +1129,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
11291129 & self ,
11301130 updates : & ChannelMonitorUpdate ,
11311131 broadcaster : & B ,
1132- fee_estimator : & F ,
1132+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
11331133 logger : & L ,
11341134 ) -> Result < ( ) , ( ) >
11351135 where
@@ -1295,8 +1295,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
12951295 F :: Target : FeeEstimator ,
12961296 L :: Target : Logger ,
12971297 {
1298+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
12981299 self . inner . lock ( ) . unwrap ( ) . transactions_confirmed (
1299- header, txdata, height, broadcaster, fee_estimator , logger)
1300+ header, txdata, height, broadcaster, & bounded_fee_estimator , logger)
13001301 }
13011302
13021303 /// Processes a transaction that was reorganized out of the chain.
@@ -1316,8 +1317,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13161317 F :: Target : FeeEstimator ,
13171318 L :: Target : Logger ,
13181319 {
1320+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
13191321 self . inner . lock ( ) . unwrap ( ) . transaction_unconfirmed (
1320- txid, broadcaster, fee_estimator , logger) ;
1322+ txid, broadcaster, & bounded_fee_estimator , logger) ;
13211323 }
13221324
13231325 /// Updates the monitor with the current best chain tip, returning new outputs to watch. See
@@ -1340,8 +1342,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13401342 F :: Target : FeeEstimator ,
13411343 L :: Target : Logger ,
13421344 {
1345+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
13431346 self . inner . lock ( ) . unwrap ( ) . best_block_updated (
1344- header, height, broadcaster, fee_estimator , logger)
1347+ header, height, broadcaster, & bounded_fee_estimator , logger)
13451348 }
13461349
13471350 /// Returns the set of txids that should be monitored for re-organization out of the chain.
@@ -1857,7 +1860,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18571860
18581861 /// Provides a payment_hash->payment_preimage mapping. Will be automatically pruned when all
18591862 /// commitment_tx_infos which contain the payment hash have been revoked.
1860- fn provide_payment_preimage < B : Deref , F : Deref , L : Deref > ( & mut self , payment_hash : & PaymentHash , payment_preimage : & PaymentPreimage , broadcaster : & B , fee_estimator : & F , logger : & L )
1863+ fn provide_payment_preimage < B : Deref , F : Deref , L : Deref > (
1864+ & mut self , payment_hash : & PaymentHash , payment_preimage : & PaymentPreimage , broadcaster : & B ,
1865+ fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L )
18611866 where B :: Target : BroadcasterInterface ,
18621867 F :: Target : FeeEstimator ,
18631868 L :: Target : Logger ,
@@ -1914,7 +1919,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19141919 self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
19151920 }
19161921
1917- pub fn update_monitor < B : Deref , F : Deref , L : Deref > ( & mut self , updates : & ChannelMonitorUpdate , broadcaster : & B , fee_estimator : & F , logger : & L ) -> Result < ( ) , ( ) >
1922+ pub ( crate ) fn update_monitor < B : Deref , F : Deref , L : Deref > ( & mut self , updates : & ChannelMonitorUpdate , broadcaster : & B , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ) -> Result < ( ) , ( ) >
19181923 where B :: Target : BroadcasterInterface ,
19191924 F :: Target : FeeEstimator ,
19201925 L :: Target : Logger ,
@@ -1955,7 +1960,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19551960 } ,
19561961 ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage } => {
19571962 log_trace ! ( logger, "Updating ChannelMonitor with payment preimage" ) ;
1958- self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, fee_estimator, logger)
1963+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1964+ self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, & bounded_fee_estimator, logger)
19591965 } ,
19601966 ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } => {
19611967 log_trace ! ( logger, "Updating ChannelMonitor with commitment secret" ) ;
@@ -2381,15 +2387,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
23812387 let block_hash = header. block_hash ( ) ;
23822388 self . best_block = BestBlock :: new ( block_hash, height) ;
23832389
2384- self . transactions_confirmed ( header, txdata, height, broadcaster, fee_estimator, logger)
2390+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2391+ self . transactions_confirmed ( header, txdata, height, broadcaster, & bounded_fee_estimator, logger)
23852392 }
23862393
23872394 fn best_block_updated < B : Deref , F : Deref , L : Deref > (
23882395 & mut self ,
23892396 header : & BlockHeader ,
23902397 height : u32 ,
23912398 broadcaster : B ,
2392- fee_estimator : F ,
2399+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
23932400 logger : L ,
23942401 ) -> Vec < TransactionOutputs >
23952402 where
@@ -2416,7 +2423,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
24162423 txdata : & TransactionData ,
24172424 height : u32 ,
24182425 broadcaster : B ,
2419- fee_estimator : F ,
2426+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
24202427 logger : L ,
24212428 ) -> Vec < TransactionOutputs >
24222429 where
@@ -2513,7 +2520,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
25132520 mut watch_outputs : Vec < TransactionOutputs > ,
25142521 mut claimable_outpoints : Vec < PackageTemplate > ,
25152522 broadcaster : & B ,
2516- fee_estimator : & F ,
2523+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
25172524 logger : & L ,
25182525 ) -> Vec < TransactionOutputs >
25192526 where
@@ -2651,7 +2658,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26512658 //- maturing spendable output has transaction paying us has been disconnected
26522659 self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height < height) ;
26532660
2654- self . onchain_tx_handler . block_disconnected ( height, broadcaster, fee_estimator, logger) ;
2661+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2662+ self . onchain_tx_handler . block_disconnected ( height, broadcaster, & bounded_fee_estimator, logger) ;
26552663
26562664 self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
26572665 }
@@ -2660,7 +2668,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26602668 & mut self ,
26612669 txid : & Txid ,
26622670 broadcaster : B ,
2663- fee_estimator : F ,
2671+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
26642672 logger : L ,
26652673 ) where
26662674 B :: Target : BroadcasterInterface ,
@@ -3390,6 +3398,8 @@ mod tests {
33903398
33913399 use hex;
33923400
3401+ use crate :: chain:: chaininterface:: LowerBoundedFeeEstimator ;
3402+
33933403 use super :: ChannelMonitorUpdateStep ;
33943404 use :: { check_added_monitors, check_closed_broadcast, check_closed_event, check_spends, get_local_commitment_txn, get_monitor, get_route_and_payment_hash, unwrap_send_err} ;
33953405 use chain:: { BestBlock , Confirm } ;
@@ -3486,7 +3496,7 @@ mod tests {
34863496
34873497 let broadcaster = TestBroadcaster :: new ( Arc :: clone ( & nodes[ 1 ] . blocks ) ) ;
34883498 assert ! (
3489- pre_update_monitor. update_monitor( & replay_update, &&broadcaster, &&chanmon_cfgs[ 1 ] . fee_estimator, & nodes[ 1 ] . logger)
3499+ pre_update_monitor. update_monitor( & replay_update, &&broadcaster, & LowerBoundedFeeEstimator :: new ( & chanmon_cfgs[ 1 ] . fee_estimator) , & nodes[ 1 ] . logger)
34903500 . is_err( ) ) ;
34913501 // Even though we error'd on the first update, we should still have generated an HTLC claim
34923502 // transaction
@@ -3511,7 +3521,7 @@ mod tests {
35113521 let secp_ctx = Secp256k1 :: new ( ) ;
35123522 let logger = Arc :: new ( TestLogger :: new ( ) ) ;
35133523 let broadcaster = Arc :: new ( TestBroadcaster { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) } ) ;
3514- let fee_estimator = Arc :: new ( TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ) ;
3524+ let fee_estimator = TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ;
35153525
35163526 let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
35173527 let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
@@ -3610,7 +3620,8 @@ mod tests {
36103620 monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
36113621 monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
36123622 for & ( ref preimage, ref hash) in preimages. iter ( ) {
3613- monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & fee_estimator, & logger) ;
3623+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( & fee_estimator) ;
3624+ monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & bounded_fee_estimator, & logger) ;
36143625 }
36153626
36163627 // Now provide a secret, pruning preimages 10-15
0 commit comments