@@ -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 ,
@@ -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.
@@ -1877,7 +1880,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1877
1880
1878
1881
/// Provides a payment_hash->payment_preimage mapping. Will be automatically pruned when all
1879
1882
/// commitment_tx_infos which contain the payment hash have been revoked.
1880
- 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 )
1883
+ fn provide_payment_preimage < B : Deref , F : Deref , L : Deref > (
1884
+ & mut self , payment_hash : & PaymentHash , payment_preimage : & PaymentPreimage , broadcaster : & B ,
1885
+ fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L )
1881
1886
where B :: Target : BroadcasterInterface ,
1882
1887
F :: Target : FeeEstimator ,
1883
1888
L :: Target : Logger ,
@@ -1975,7 +1980,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1975
1980
} ,
1976
1981
ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage } => {
1977
1982
log_trace ! ( logger, "Updating ChannelMonitor with payment preimage" ) ;
1978
- self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, fee_estimator, logger)
1983
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
1984
+ self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage, broadcaster, & bounded_fee_estimator, logger)
1979
1985
} ,
1980
1986
ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } => {
1981
1987
log_trace ! ( logger, "Updating ChannelMonitor with commitment secret" ) ;
@@ -2401,15 +2407,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2401
2407
let block_hash = header. block_hash ( ) ;
2402
2408
self . best_block = BestBlock :: new ( block_hash, height) ;
2403
2409
2404
- self . transactions_confirmed ( header, txdata, height, broadcaster, fee_estimator, logger)
2410
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2411
+ self . transactions_confirmed ( header, txdata, height, broadcaster, & bounded_fee_estimator, logger)
2405
2412
}
2406
2413
2407
2414
fn best_block_updated < B : Deref , F : Deref , L : Deref > (
2408
2415
& mut self ,
2409
2416
header : & BlockHeader ,
2410
2417
height : u32 ,
2411
2418
broadcaster : B ,
2412
- fee_estimator : F ,
2419
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2413
2420
logger : L ,
2414
2421
) -> Vec < TransactionOutputs >
2415
2422
where
@@ -2436,7 +2443,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2436
2443
txdata : & TransactionData ,
2437
2444
height : u32 ,
2438
2445
broadcaster : B ,
2439
- fee_estimator : F ,
2446
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2440
2447
logger : L ,
2441
2448
) -> Vec < TransactionOutputs >
2442
2449
where
@@ -2533,7 +2540,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2533
2540
mut watch_outputs : Vec < TransactionOutputs > ,
2534
2541
mut claimable_outpoints : Vec < PackageTemplate > ,
2535
2542
broadcaster : & B ,
2536
- fee_estimator : & F ,
2543
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2537
2544
logger : & L ,
2538
2545
) -> Vec < TransactionOutputs >
2539
2546
where
@@ -2671,7 +2678,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2671
2678
//- maturing spendable output has transaction paying us has been disconnected
2672
2679
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height < height) ;
2673
2680
2674
- self . onchain_tx_handler . block_disconnected ( height, broadcaster, fee_estimator, logger) ;
2681
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
2682
+ self . onchain_tx_handler . block_disconnected ( height, broadcaster, & bounded_fee_estimator, logger) ;
2675
2683
2676
2684
self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
2677
2685
}
@@ -2680,7 +2688,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2680
2688
& mut self ,
2681
2689
txid : & Txid ,
2682
2690
broadcaster : B ,
2683
- fee_estimator : F ,
2691
+ fee_estimator : & LowerBoundedFeeEstimator < F > ,
2684
2692
logger : L ,
2685
2693
) where
2686
2694
B :: Target : BroadcasterInterface ,
@@ -3420,6 +3428,8 @@ mod tests {
3420
3428
3421
3429
use hex;
3422
3430
3431
+ use crate :: chain:: chaininterface:: LowerBoundedFeeEstimator ;
3432
+
3423
3433
use super :: ChannelMonitorUpdateStep ;
3424
3434
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} ;
3425
3435
use chain:: { BestBlock , Confirm } ;
@@ -3541,7 +3551,7 @@ mod tests {
3541
3551
let secp_ctx = Secp256k1 :: new ( ) ;
3542
3552
let logger = Arc :: new ( TestLogger :: new ( ) ) ;
3543
3553
let broadcaster = Arc :: new ( TestBroadcaster { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) } ) ;
3544
- let fee_estimator = Arc :: new ( TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ) ;
3554
+ let fee_estimator = TestFeeEstimator { sat_per_kw : Mutex :: new ( 253 ) } ;
3545
3555
3546
3556
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
3547
3557
let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
@@ -3640,7 +3650,8 @@ mod tests {
3640
3650
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
3641
3651
monitor. provide_latest_counterparty_commitment_tx ( dummy_txid, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
3642
3652
for & ( ref preimage, ref hash) in preimages. iter ( ) {
3643
- monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & fee_estimator, & logger) ;
3653
+ let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( & fee_estimator) ;
3654
+ monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & bounded_fee_estimator, & logger) ;
3644
3655
}
3645
3656
3646
3657
// Now provide a secret, pruning preimages 10-15
0 commit comments