@@ -40,7 +40,7 @@ use ln::chan_utils::{CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLC
40
40
use ln:: channelmanager:: HTLCSource ;
41
41
use chain;
42
42
use chain:: { BestBlock , WatchedOutput } ;
43
- use chain:: chaininterface:: { BroadcasterInterface , FeeEstimator } ;
43
+ use chain:: chaininterface:: { BroadcasterInterface , FeeEstimator , LowerBoundedFeeEstimator } ;
44
44
use chain:: transaction:: { OutPoint , TransactionData } ;
45
45
use chain:: keysinterface:: { SpendableOutputDescriptor , StaticPaymentOutputDescriptor , DelayedPaymentOutputDescriptor , Sign , KeysInterface } ;
46
46
use chain:: onchaintx:: OnchainTxHandler ;
@@ -1099,7 +1099,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1099
1099
payment_hash : & PaymentHash ,
1100
1100
payment_preimage : & PaymentPreimage ,
1101
1101
broadcaster : & B ,
1102
- fee_estimator : & F ,
1102
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
1103
1103
logger : & L ,
1104
1104
) where
1105
1105
B :: Target : BroadcasterInterface ,
@@ -1129,7 +1129,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1129
1129
& self ,
1130
1130
updates : & ChannelMonitorUpdate ,
1131
1131
broadcaster : & B ,
1132
- fee_estimator : & F ,
1132
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
1133
1133
logger : & L ,
1134
1134
) -> Result < ( ) , ( ) >
1135
1135
where
@@ -1295,8 +1295,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1295
1295
F :: Target : FeeEstimator ,
1296
1296
L :: Target : Logger ,
1297
1297
{
1298
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1298
1299
self . inner . lock ( ) . unwrap ( ) . transactions_confirmed (
1299
- header, txdata, height, broadcaster, fee_estimator , logger)
1300
+ header, txdata, height, broadcaster, & bounded_fee_estimator , logger)
1300
1301
}
1301
1302
1302
1303
/// Processes a transaction that was reorganized out of the chain.
@@ -1316,8 +1317,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1316
1317
F :: Target : FeeEstimator ,
1317
1318
L :: Target : Logger ,
1318
1319
{
1320
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1319
1321
self . inner . lock ( ) . unwrap ( ) . transaction_unconfirmed (
1320
- txid, broadcaster, fee_estimator , logger) ;
1322
+ txid, broadcaster, & bounded_fee_estimator , logger) ;
1321
1323
}
1322
1324
1323
1325
/// Updates the monitor with the current best chain tip, returning new outputs to watch. See
@@ -1340,8 +1342,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1340
1342
F :: Target : FeeEstimator ,
1341
1343
L :: Target : Logger ,
1342
1344
{
1345
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1343
1346
self . inner . lock ( ) . unwrap ( ) . best_block_updated (
1344
- header, height, broadcaster, fee_estimator , logger)
1347
+ header, height, broadcaster, & bounded_fee_estimator , logger)
1345
1348
}
1346
1349
1347
1350
/// 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> {
1857
1860
1858
1861
/// Provides a payment_hash->payment_preimage mapping. Will be automatically pruned when all
1859
1862
/// 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 )
1861
1866
where B :: Target : BroadcasterInterface ,
1862
1867
F :: Target : FeeEstimator ,
1863
1868
L :: Target : Logger ,
@@ -1914,7 +1919,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1914
1919
self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
1915
1920
}
1916
1921
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 < ( ) , ( ) >
1918
1923
where B :: Target : BroadcasterInterface ,
1919
1924
F :: Target : FeeEstimator ,
1920
1925
L :: Target : Logger ,
@@ -1955,7 +1960,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1955
1960
} ,
1956
1961
ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage } => {
1957
1962
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)
1959
1965
} ,
1960
1966
ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } => {
1961
1967
log_trace ! ( logger, "Updating ChannelMonitor with commitment secret" ) ;
@@ -2381,15 +2387,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2381
2387
let block_hash = header. block_hash ( ) ;
2382
2388
self . best_block = BestBlock :: new ( block_hash, height) ;
2383
2389
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)
2385
2392
}
2386
2393
2387
2394
fn best_block_updated < B : Deref , F : Deref , L : Deref > (
2388
2395
& mut self ,
2389
2396
header : & BlockHeader ,
2390
2397
height : u32 ,
2391
2398
broadcaster : B ,
2392
- fee_estimator : F ,
2399
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2393
2400
logger : L ,
2394
2401
) -> Vec < TransactionOutputs >
2395
2402
where
@@ -2416,7 +2423,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2416
2423
txdata : & TransactionData ,
2417
2424
height : u32 ,
2418
2425
broadcaster : B ,
2419
- fee_estimator : F ,
2426
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2420
2427
logger : L ,
2421
2428
) -> Vec < TransactionOutputs >
2422
2429
where
@@ -2513,7 +2520,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2513
2520
mut watch_outputs : Vec < TransactionOutputs > ,
2514
2521
mut claimable_outpoints : Vec < PackageTemplate > ,
2515
2522
broadcaster : & B ,
2516
- fee_estimator : & F ,
2523
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2517
2524
logger : & L ,
2518
2525
) -> Vec < TransactionOutputs >
2519
2526
where
@@ -2651,7 +2658,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2651
2658
//- maturing spendable output has transaction paying us has been disconnected
2652
2659
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height < height) ;
2653
2660
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) ;
2655
2663
2656
2664
self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
2657
2665
}
@@ -2660,7 +2668,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2660
2668
& mut self ,
2661
2669
txid : & Txid ,
2662
2670
broadcaster : B ,
2663
- fee_estimator : F ,
2671
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2664
2672
logger : L ,
2665
2673
) where
2666
2674
B :: Target : BroadcasterInterface ,
@@ -3390,6 +3398,8 @@ mod tests {
3390
3398
3391
3399
use hex;
3392
3400
3401
+ use crate :: chain:: chaininterface:: LowerBoundedFeeEstimator ;
3402
+
3393
3403
use super :: ChannelMonitorUpdateStep ;
3394
3404
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} ;
3395
3405
use chain:: { BestBlock , Confirm } ;
@@ -3486,7 +3496,7 @@ mod tests {
3486
3496
3487
3497
let broadcaster = TestBroadcaster :: new ( Arc :: clone ( & nodes[ 1 ] . blocks ) ) ;
3488
3498
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)
3490
3500
. is_err( ) ) ;
3491
3501
// Even though we error'd on the first update, we should still have generated an HTLC claim
3492
3502
// transaction
@@ -3511,7 +3521,7 @@ mod tests {
3511
3521
let secp_ctx = Secp256k1 :: new ( ) ;
3512
3522
let logger = Arc :: new ( TestLogger :: new ( ) ) ;
3513
3523
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 ) } ;
3515
3525
3516
3526
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
3517
3527
let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
@@ -3610,7 +3620,8 @@ mod tests {
3610
3620
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
3611
3621
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
3612
3622
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) ;
3614
3625
}
3615
3626
3616
3627
// Now provide a secret, pruning preimages 10-15
0 commit comments