@@ -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 ;
@@ -1104,7 +1104,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1104
1104
payment_hash : & PaymentHash ,
1105
1105
payment_preimage : & PaymentPreimage ,
1106
1106
broadcaster : & B ,
1107
- fee_estimator : & F ,
1107
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
1108
1108
logger : & L ,
1109
1109
) where
1110
1110
B :: Target : BroadcasterInterface ,
@@ -1300,8 +1300,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1300
1300
F :: Target : FeeEstimator ,
1301
1301
L :: Target : Logger ,
1302
1302
{
1303
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1303
1304
self . inner . lock ( ) . unwrap ( ) . transactions_confirmed (
1304
- header, txdata, height, broadcaster, fee_estimator , logger)
1305
+ header, txdata, height, broadcaster, & bounded_fee_estimator , logger)
1305
1306
}
1306
1307
1307
1308
/// Processes a transaction that was reorganized out of the chain.
@@ -1321,8 +1322,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1321
1322
F :: Target : FeeEstimator ,
1322
1323
L :: Target : Logger ,
1323
1324
{
1325
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1324
1326
self . inner . lock ( ) . unwrap ( ) . transaction_unconfirmed (
1325
- txid, broadcaster, fee_estimator , logger) ;
1327
+ txid, broadcaster, & bounded_fee_estimator , logger) ;
1326
1328
}
1327
1329
1328
1330
/// Updates the monitor with the current best chain tip, returning new outputs to watch. See
@@ -1345,8 +1347,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1345
1347
F :: Target : FeeEstimator ,
1346
1348
L :: Target : Logger ,
1347
1349
{
1350
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1348
1351
self . inner . lock ( ) . unwrap ( ) . best_block_updated (
1349
- header, height, broadcaster, fee_estimator , logger)
1352
+ header, height, broadcaster, & bounded_fee_estimator , logger)
1350
1353
}
1351
1354
1352
1355
/// Returns the set of txids that should be monitored for re-organization out of the chain.
@@ -1882,7 +1885,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1882
1885
1883
1886
/// Provides a payment_hash->payment_preimage mapping. Will be automatically pruned when all
1884
1887
/// commitment_tx_infos which contain the payment hash have been revoked.
1885
- 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 )
1888
+ fn provide_payment_preimage < B : Deref , F : Deref , L : Deref > (
1889
+ & mut self , payment_hash : & PaymentHash , payment_preimage : & PaymentPreimage , broadcaster : & B ,
1890
+ fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L )
1886
1891
where B :: Target : BroadcasterInterface ,
1887
1892
F :: Target : FeeEstimator ,
1888
1893
L :: Target : Logger ,
@@ -1980,7 +1985,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1980
1985
} ,
1981
1986
ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage } => {
1982
1987
log_trace ! ( logger, "Updating ChannelMonitor with payment preimage" ) ;
1983
- self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, fee_estimator, logger)
1988
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1989
+ self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, & bounded_fee_estimator, logger)
1984
1990
} ,
1985
1991
ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } => {
1986
1992
log_trace ! ( logger, "Updating ChannelMonitor with commitment secret" ) ;
@@ -2406,15 +2412,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2406
2412
let block_hash = header. block_hash ( ) ;
2407
2413
self . best_block = BestBlock :: new ( block_hash, height) ;
2408
2414
2409
- self . transactions_confirmed ( header, txdata, height, broadcaster, fee_estimator, logger)
2415
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2416
+ self . transactions_confirmed ( header, txdata, height, broadcaster, & bounded_fee_estimator, logger)
2410
2417
}
2411
2418
2412
2419
fn best_block_updated < B : Deref , F : Deref , L : Deref > (
2413
2420
& mut self ,
2414
2421
header : & BlockHeader ,
2415
2422
height : u32 ,
2416
2423
broadcaster : B ,
2417
- fee_estimator : F ,
2424
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2418
2425
logger : L ,
2419
2426
) -> Vec < TransactionOutputs >
2420
2427
where
@@ -2441,7 +2448,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2441
2448
txdata : & TransactionData ,
2442
2449
height : u32 ,
2443
2450
broadcaster : B ,
2444
- fee_estimator : F ,
2451
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2445
2452
logger : L ,
2446
2453
) -> Vec < TransactionOutputs >
2447
2454
where
@@ -2538,7 +2545,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2538
2545
mut watch_outputs : Vec < TransactionOutputs > ,
2539
2546
mut claimable_outpoints : Vec < PackageTemplate > ,
2540
2547
broadcaster : & B ,
2541
- fee_estimator : & F ,
2548
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2542
2549
logger : & L ,
2543
2550
) -> Vec < TransactionOutputs >
2544
2551
where
@@ -2676,7 +2683,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2676
2683
//- maturing spendable output has transaction paying us has been disconnected
2677
2684
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height < height) ;
2678
2685
2679
- self . onchain_tx_handler . block_disconnected ( height, broadcaster, fee_estimator, logger) ;
2686
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2687
+ self . onchain_tx_handler . block_disconnected ( height, broadcaster, & bounded_fee_estimator, logger) ;
2680
2688
2681
2689
self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
2682
2690
}
@@ -2685,7 +2693,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2685
2693
& mut self ,
2686
2694
txid : & Txid ,
2687
2695
broadcaster : B ,
2688
- fee_estimator : F ,
2696
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2689
2697
logger : L ,
2690
2698
) where
2691
2699
B :: Target : BroadcasterInterface ,
@@ -3428,6 +3436,8 @@ mod tests {
3428
3436
3429
3437
use hex;
3430
3438
3439
+ use crate :: chain:: chaininterface:: LowerBoundedFeeEstimator ;
3440
+
3431
3441
use super :: ChannelMonitorUpdateStep ;
3432
3442
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} ;
3433
3443
use chain:: { BestBlock , Confirm } ;
@@ -3549,7 +3559,7 @@ mod tests {
3549
3559
let secp_ctx = Secp256k1 :: new ( ) ;
3550
3560
let logger = Arc :: new ( TestLogger :: new ( ) ) ;
3551
3561
let broadcaster = Arc :: new ( TestBroadcaster { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) } ) ;
3552
- let fee_estimator = Arc :: new ( TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ) ;
3562
+ let fee_estimator = TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ;
3553
3563
3554
3564
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
3555
3565
let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
@@ -3648,7 +3658,8 @@ mod tests {
3648
3658
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
3649
3659
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
3650
3660
for & ( ref preimage, ref hash) in preimages. iter ( ) {
3651
- monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & fee_estimator, & logger) ;
3661
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( & fee_estimator) ;
3662
+ monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & bounded_fee_estimator, & logger) ;
3652
3663
}
3653
3664
3654
3665
// Now provide a secret, pruning preimages 10-15
0 commit comments