@@ -1069,7 +1069,10 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
1069
1069
cmp:: max ( self . config . options . cltv_expiry_delta , MIN_CLTV_EXPIRY_DELTA )
1070
1070
}
1071
1071
1072
- pub fn get_max_dust_htlc_exposure_msat ( & self ) -> u64 {
1072
+ pub fn get_max_dust_htlc_exposure_msat < F : Deref > ( & self ,
1073
+ _fee_estimator : & LowerBoundedFeeEstimator < F > ) -> u64
1074
+ where F :: Target : FeeEstimator
1075
+ {
1073
1076
self . config . options . max_dust_htlc_exposure_msat
1074
1077
}
1075
1078
@@ -1544,7 +1547,9 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
1544
1547
/// Doesn't bother handling the
1545
1548
/// if-we-removed-it-already-but-haven't-fully-resolved-they-can-still-send-an-inbound-HTLC
1546
1549
/// corner case properly.
1547
- pub fn get_available_balances ( & self ) -> AvailableBalances {
1550
+ pub fn get_available_balances < F : Deref > ( & self , fee_estimator : & LowerBoundedFeeEstimator < F > ) -> AvailableBalances
1551
+ where F :: Target : FeeEstimator
1552
+ {
1548
1553
let context = & self ;
1549
1554
// Note that we have to handle overflow due to the above case.
1550
1555
let inbound_stats = context. get_inbound_pending_htlc_stats ( None ) ;
@@ -1626,6 +1631,7 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
1626
1631
// send above the dust limit (as the router can always overpay to meet the dust limit).
1627
1632
let mut remaining_msat_below_dust_exposure_limit = None ;
1628
1633
let mut dust_exposure_dust_limit_msat = 0 ;
1634
+ let max_dust_htlc_exposure_msat = context. get_max_dust_htlc_exposure_msat ( fee_estimator) ;
1629
1635
1630
1636
let ( htlc_success_dust_limit, htlc_timeout_dust_limit) = if context. opt_anchors ( ) {
1631
1637
( context. counterparty_dust_limit_satoshis , context. holder_dust_limit_satoshis )
@@ -1635,17 +1641,17 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
1635
1641
context. holder_dust_limit_satoshis + dust_buffer_feerate * htlc_timeout_tx_weight ( false ) / 1000 )
1636
1642
} ;
1637
1643
let on_counterparty_dust_htlc_exposure_msat = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat ;
1638
- if on_counterparty_dust_htlc_exposure_msat as i64 + htlc_success_dust_limit as i64 * 1000 - 1 > context . get_max_dust_htlc_exposure_msat ( ) as i64 {
1644
+ if on_counterparty_dust_htlc_exposure_msat as i64 + htlc_success_dust_limit as i64 * 1000 - 1 > max_dust_htlc_exposure_msat as i64 {
1639
1645
remaining_msat_below_dust_exposure_limit =
1640
- Some ( context . get_max_dust_htlc_exposure_msat ( ) . saturating_sub ( on_counterparty_dust_htlc_exposure_msat) ) ;
1646
+ Some ( max_dust_htlc_exposure_msat . saturating_sub ( on_counterparty_dust_htlc_exposure_msat) ) ;
1641
1647
dust_exposure_dust_limit_msat = cmp:: max ( dust_exposure_dust_limit_msat, htlc_success_dust_limit * 1000 ) ;
1642
1648
}
1643
1649
1644
1650
let on_holder_dust_htlc_exposure_msat = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat ;
1645
- if on_holder_dust_htlc_exposure_msat as i64 + htlc_timeout_dust_limit as i64 * 1000 - 1 > context . get_max_dust_htlc_exposure_msat ( ) as i64 {
1651
+ if on_holder_dust_htlc_exposure_msat as i64 + htlc_timeout_dust_limit as i64 * 1000 - 1 > max_dust_htlc_exposure_msat as i64 {
1646
1652
remaining_msat_below_dust_exposure_limit = Some ( cmp:: min (
1647
1653
remaining_msat_below_dust_exposure_limit. unwrap_or ( u64:: max_value ( ) ) ,
1648
- context . get_max_dust_htlc_exposure_msat ( ) . saturating_sub ( on_holder_dust_htlc_exposure_msat) ) ) ;
1654
+ max_dust_htlc_exposure_msat . saturating_sub ( on_holder_dust_htlc_exposure_msat) ) ) ;
1649
1655
dust_exposure_dust_limit_msat = cmp:: max ( dust_exposure_dust_limit_msat, htlc_timeout_dust_limit * 1000 ) ;
1650
1656
}
1651
1657
@@ -2576,8 +2582,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2576
2582
Ok ( self . get_announcement_sigs ( node_signer, genesis_block_hash, user_config, best_block. height ( ) , logger) )
2577
2583
}
2578
2584
2579
- pub fn update_add_htlc < F , L : Deref > ( & mut self , msg : & msgs:: UpdateAddHTLC , mut pending_forward_status : PendingHTLCStatus , create_pending_htlc_status : F , logger : & L ) -> Result < ( ) , ChannelError >
2580
- where F : for < ' a > Fn ( & ' a Self , PendingHTLCStatus , u16 ) -> PendingHTLCStatus , L :: Target : Logger {
2585
+ pub fn update_add_htlc < F , FE : Deref , L : Deref > ( & mut self , msg : & msgs:: UpdateAddHTLC , mut pending_forward_status : PendingHTLCStatus , create_pending_htlc_status : F , fee_estimator : & LowerBoundedFeeEstimator < FE > , logger : & L ) -> Result < ( ) , ChannelError >
2586
+ where F : for < ' a > Fn ( & ' a Self , PendingHTLCStatus , u16 ) -> PendingHTLCStatus ,
2587
+ FE :: Target : FeeEstimator , L :: Target : Logger {
2581
2588
// We can't accept HTLCs sent after we've sent a shutdown.
2582
2589
let local_sent_shutdown = ( self . context . channel_state & ( ChannelState :: ChannelReady as u32 | ChannelState :: LocalShutdownSent as u32 ) ) != ( ChannelState :: ChannelReady as u32 ) ;
2583
2590
if local_sent_shutdown {
@@ -2630,6 +2637,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2630
2637
}
2631
2638
}
2632
2639
2640
+ let max_dust_htlc_exposure_msat = self . context . get_max_dust_htlc_exposure_msat ( fee_estimator) ;
2633
2641
let ( htlc_timeout_dust_limit, htlc_success_dust_limit) = if self . context . opt_anchors ( ) {
2634
2642
( 0 , 0 )
2635
2643
} else {
@@ -2640,19 +2648,19 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2640
2648
let exposure_dust_limit_timeout_sats = htlc_timeout_dust_limit + self . context . counterparty_dust_limit_satoshis ;
2641
2649
if msg. amount_msat / 1000 < exposure_dust_limit_timeout_sats {
2642
2650
let on_counterparty_tx_dust_htlc_exposure_msat = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat + msg. amount_msat ;
2643
- if on_counterparty_tx_dust_htlc_exposure_msat > self . context . get_max_dust_htlc_exposure_msat ( ) {
2651
+ if on_counterparty_tx_dust_htlc_exposure_msat > max_dust_htlc_exposure_msat {
2644
2652
log_info ! ( logger, "Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on counterparty commitment tx" ,
2645
- on_counterparty_tx_dust_htlc_exposure_msat, self . context . get_max_dust_htlc_exposure_msat ( ) ) ;
2653
+ on_counterparty_tx_dust_htlc_exposure_msat, max_dust_htlc_exposure_msat ) ;
2646
2654
pending_forward_status = create_pending_htlc_status ( self , pending_forward_status, 0x1000 |7 ) ;
2647
2655
}
2648
2656
}
2649
2657
2650
2658
let exposure_dust_limit_success_sats = htlc_success_dust_limit + self . context . holder_dust_limit_satoshis ;
2651
2659
if msg. amount_msat / 1000 < exposure_dust_limit_success_sats {
2652
2660
let on_holder_tx_dust_htlc_exposure_msat = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat + msg. amount_msat ;
2653
- if on_holder_tx_dust_htlc_exposure_msat > self . context . get_max_dust_htlc_exposure_msat ( ) {
2661
+ if on_holder_tx_dust_htlc_exposure_msat > max_dust_htlc_exposure_msat {
2654
2662
log_info ! ( logger, "Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on holder commitment tx" ,
2655
- on_holder_tx_dust_htlc_exposure_msat, self . context . get_max_dust_htlc_exposure_msat ( ) ) ;
2663
+ on_holder_tx_dust_htlc_exposure_msat, max_dust_htlc_exposure_msat ) ;
2656
2664
pending_forward_status = create_pending_htlc_status ( self , pending_forward_status, 0x1000 |7 ) ;
2657
2665
}
2658
2666
}
@@ -3019,16 +3027,18 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3019
3027
/// Public version of the below, checking relevant preconditions first.
3020
3028
/// If we're not in a state where freeing the holding cell makes sense, this is a no-op and
3021
3029
/// returns `(None, Vec::new())`.
3022
- pub fn maybe_free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3030
+ pub fn maybe_free_holding_cell_htlcs < F : Deref , L : Deref > ( & mut self , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where F :: Target : FeeEstimator , L :: Target : Logger {
3023
3031
if self . context . channel_state >= ChannelState :: ChannelReady as u32 &&
3024
3032
( self . context . channel_state & ( ChannelState :: AwaitingRemoteRevoke as u32 | ChannelState :: PeerDisconnected as u32 | ChannelState :: MonitorUpdateInProgress as u32 ) ) == 0 {
3025
- self . free_holding_cell_htlcs ( logger)
3033
+ self . free_holding_cell_htlcs ( fee_estimator , logger)
3026
3034
} else { ( None , Vec :: new ( ) ) }
3027
3035
}
3028
3036
3029
3037
/// Frees any pending commitment updates in the holding cell, generating the relevant messages
3030
3038
/// for our counterparty.
3031
- fn free_holding_cell_htlcs < L : Deref > ( & mut self , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > ) where L :: Target : Logger {
3039
+ fn free_holding_cell_htlcs < F : Deref , L : Deref > ( & mut self , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ) -> ( Option < & ChannelMonitorUpdate > , Vec < ( HTLCSource , PaymentHash ) > )
3040
+ where F :: Target : FeeEstimator , L :: Target : Logger
3041
+ {
3032
3042
assert_eq ! ( self . context. channel_state & ChannelState :: MonitorUpdateInProgress as u32 , 0 ) ;
3033
3043
if self . context . holding_cell_htlc_updates . len ( ) != 0 || self . context . holding_cell_update_fee . is_some ( ) {
3034
3044
log_trace ! ( logger, "Freeing holding cell with {} HTLC updates{} in channel {}" , self . context. holding_cell_htlc_updates. len( ) ,
@@ -3053,7 +3063,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3053
3063
// to rebalance channels.
3054
3064
match & htlc_update {
3055
3065
& HTLCUpdateAwaitingACK :: AddHTLC { amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet, ..} => {
3056
- match self . send_htlc ( amount_msat, * payment_hash, cltv_expiry, source. clone ( ) , onion_routing_packet. clone ( ) , false , logger) {
3066
+ match self . send_htlc ( amount_msat, * payment_hash, cltv_expiry, source. clone ( ) , onion_routing_packet. clone ( ) , false , fee_estimator , logger) {
3057
3067
Ok ( update_add_msg_option) => update_add_htlcs. push ( update_add_msg_option. unwrap ( ) ) ,
3058
3068
Err ( e) => {
3059
3069
match e {
@@ -3112,7 +3122,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3112
3122
return ( None , htlcs_to_fail) ;
3113
3123
}
3114
3124
let update_fee = if let Some ( feerate) = self . context . holding_cell_update_fee . take ( ) {
3115
- self . send_update_fee ( feerate, false , logger)
3125
+ self . send_update_fee ( feerate, false , fee_estimator , logger)
3116
3126
} else {
3117
3127
None
3118
3128
} ;
@@ -3139,8 +3149,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3139
3149
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
3140
3150
/// generating an appropriate error *after* the channel state has been updated based on the
3141
3151
/// revoke_and_ack message.
3142
- pub fn revoke_and_ack < L : Deref > ( & mut self , msg : & msgs:: RevokeAndACK , logger : & L ) -> Result < ( Vec < ( HTLCSource , PaymentHash ) > , Option < & ChannelMonitorUpdate > ) , ChannelError >
3143
- where L :: Target : Logger ,
3152
+ pub fn revoke_and_ack < F : Deref , L : Deref > ( & mut self , msg : & msgs:: RevokeAndACK , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ) -> Result < ( Vec < ( HTLCSource , PaymentHash ) > , Option < & ChannelMonitorUpdate > ) , ChannelError >
3153
+ where F :: Target : FeeEstimator , L :: Target : Logger ,
3144
3154
{
3145
3155
if ( self . context . channel_state & ( ChannelState :: ChannelReady as u32 ) ) != ( ChannelState :: ChannelReady as u32 ) {
3146
3156
return Err ( ChannelError :: Close ( "Got revoke/ACK message when channel was not in an operational state" . to_owned ( ) ) ) ;
@@ -3340,7 +3350,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3340
3350
return Ok ( ( Vec :: new ( ) , self . push_ret_blockable_mon_update ( monitor_update) ) ) ;
3341
3351
}
3342
3352
3343
- match self . free_holding_cell_htlcs ( logger) {
3353
+ match self . free_holding_cell_htlcs ( fee_estimator , logger) {
3344
3354
( Some ( _) , htlcs_to_fail) => {
3345
3355
let mut additional_update = self . context . pending_monitor_updates . pop ( ) . unwrap ( ) . update ;
3346
3356
// free_holding_cell_htlcs may bump latest_monitor_id multiple times but we want them to be
@@ -3376,8 +3386,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3376
3386
/// Queues up an outbound update fee by placing it in the holding cell. You should call
3377
3387
/// [`Self::maybe_free_holding_cell_htlcs`] in order to actually generate and send the
3378
3388
/// commitment update.
3379
- pub fn queue_update_fee < L : Deref > ( & mut self , feerate_per_kw : u32 , logger : & L ) where L :: Target : Logger {
3380
- let msg_opt = self . send_update_fee ( feerate_per_kw, true , logger) ;
3389
+ pub fn queue_update_fee < F : Deref , L : Deref > ( & mut self , feerate_per_kw : u32 ,
3390
+ fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L )
3391
+ where F :: Target : FeeEstimator , L :: Target : Logger
3392
+ {
3393
+ let msg_opt = self . send_update_fee ( feerate_per_kw, true , fee_estimator, logger) ;
3381
3394
assert ! ( msg_opt. is_none( ) , "We forced holding cell?" ) ;
3382
3395
}
3383
3396
@@ -3388,7 +3401,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3388
3401
///
3389
3402
/// You MUST call [`Self::send_commitment_no_state_update`] prior to any other calls on this
3390
3403
/// [`Channel`] if `force_holding_cell` is false.
3391
- fn send_update_fee < L : Deref > ( & mut self , feerate_per_kw : u32 , mut force_holding_cell : bool , logger : & L ) -> Option < msgs:: UpdateFee > where L :: Target : Logger {
3404
+ fn send_update_fee < F : Deref , L : Deref > ( & mut self , feerate_per_kw : u32 , mut force_holding_cell : bool , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ) -> Option < msgs:: UpdateFee >
3405
+ where F :: Target : FeeEstimator , L :: Target : Logger
3406
+ {
3392
3407
if !self . context . is_outbound ( ) {
3393
3408
panic ! ( "Cannot send fee from inbound channel" ) ;
3394
3409
}
@@ -3415,11 +3430,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3415
3430
// Note, we evaluate pending htlc "preemptive" trimmed-to-dust threshold at the proposed `feerate_per_kw`.
3416
3431
let holder_tx_dust_exposure = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat ;
3417
3432
let counterparty_tx_dust_exposure = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat ;
3418
- if holder_tx_dust_exposure > self . context . get_max_dust_htlc_exposure_msat ( ) {
3433
+ let max_dust_htlc_exposure_msat = self . context . get_max_dust_htlc_exposure_msat ( fee_estimator) ;
3434
+ if holder_tx_dust_exposure > max_dust_htlc_exposure_msat {
3419
3435
log_debug ! ( logger, "Cannot afford to send new feerate at {} without infringing max dust htlc exposure" , feerate_per_kw) ;
3420
3436
return None ;
3421
3437
}
3422
- if counterparty_tx_dust_exposure > self . context . get_max_dust_htlc_exposure_msat ( ) {
3438
+ if counterparty_tx_dust_exposure > max_dust_htlc_exposure_msat {
3423
3439
log_debug ! ( logger, "Cannot afford to send new feerate at {} without infringing max dust htlc exposure" , feerate_per_kw) ;
3424
3440
return None ;
3425
3441
}
@@ -3656,11 +3672,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3656
3672
let outbound_stats = self . context . get_outbound_pending_htlc_stats ( None ) ;
3657
3673
let holder_tx_dust_exposure = inbound_stats. on_holder_tx_dust_exposure_msat + outbound_stats. on_holder_tx_dust_exposure_msat ;
3658
3674
let counterparty_tx_dust_exposure = inbound_stats. on_counterparty_tx_dust_exposure_msat + outbound_stats. on_counterparty_tx_dust_exposure_msat ;
3659
- if holder_tx_dust_exposure > self . context . get_max_dust_htlc_exposure_msat ( ) {
3675
+ let max_dust_htlc_exposure_msat = self . context . get_max_dust_htlc_exposure_msat ( fee_estimator) ;
3676
+ if holder_tx_dust_exposure > max_dust_htlc_exposure_msat {
3660
3677
return Err ( ChannelError :: Close ( format ! ( "Peer sent update_fee with a feerate ({}) which may over-expose us to dust-in-flight on our own transactions (totaling {} msat)" ,
3661
3678
msg. feerate_per_kw, holder_tx_dust_exposure) ) ) ;
3662
3679
}
3663
- if counterparty_tx_dust_exposure > self . context . get_max_dust_htlc_exposure_msat ( ) {
3680
+ if counterparty_tx_dust_exposure > max_dust_htlc_exposure_msat {
3664
3681
return Err ( ChannelError :: Close ( format ! ( "Peer sent update_fee with a feerate ({}) which may over-expose us to dust-in-flight on our counterparty's transactions (totaling {} msat)" ,
3665
3682
msg. feerate_per_kw, counterparty_tx_dust_exposure) ) ) ;
3666
3683
}
@@ -5042,11 +5059,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5042
5059
/// commitment update.
5043
5060
///
5044
5061
/// `Err`s will only be [`ChannelError::Ignore`].
5045
- pub fn queue_add_htlc < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5046
- onion_routing_packet : msgs:: OnionPacket , logger : & L )
5047
- -> Result < ( ) , ChannelError > where L :: Target : Logger {
5062
+ pub fn queue_add_htlc < F : Deref , L : Deref > ( & mut self , amount_msat : u64 ,
5063
+ payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5064
+ onion_routing_packet : msgs:: OnionPacket , fee_estimator : & LowerBoundedFeeEstimator < F > ,
5065
+ logger : & L ) -> Result < ( ) , ChannelError >
5066
+ where F :: Target : FeeEstimator , L :: Target : Logger
5067
+ {
5048
5068
self
5049
- . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true , logger)
5069
+ . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true ,
5070
+ fee_estimator, logger)
5050
5071
. map ( |msg_opt| assert ! ( msg_opt. is_none( ) , "We forced holding cell?" ) )
5051
5072
. map_err ( |err| {
5052
5073
if let ChannelError :: Ignore ( _) = err { /* fine */ }
@@ -5071,9 +5092,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5071
5092
/// on this [`Channel`] if `force_holding_cell` is false.
5072
5093
///
5073
5094
/// `Err`s will only be [`ChannelError::Ignore`].
5074
- fn send_htlc < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5075
- onion_routing_packet : msgs:: OnionPacket , mut force_holding_cell : bool , logger : & L )
5076
- -> Result < Option < msgs:: UpdateAddHTLC > , ChannelError > where L :: Target : Logger {
5095
+ fn send_htlc < F : Deref , L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5096
+ onion_routing_packet : msgs:: OnionPacket , mut force_holding_cell : bool , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L )
5097
+ -> Result < Option < msgs:: UpdateAddHTLC > , ChannelError >
5098
+ where F :: Target : FeeEstimator , L :: Target : Logger
5099
+ {
5077
5100
if ( self . context . channel_state & ( ChannelState :: ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK ) ) != ( ChannelState :: ChannelReady as u32 ) {
5078
5101
return Err ( ChannelError :: Ignore ( "Cannot send HTLC until channel is fully established and we haven't started shutting down" . to_owned ( ) ) ) ;
5079
5102
}
@@ -5086,7 +5109,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5086
5109
return Err ( ChannelError :: Ignore ( "Cannot send 0-msat HTLC" . to_owned ( ) ) ) ;
5087
5110
}
5088
5111
5089
- let available_balances = self . context . get_available_balances ( ) ;
5112
+ let available_balances = self . context . get_available_balances ( fee_estimator ) ;
5090
5113
if amount_msat < available_balances. next_outbound_htlc_minimum_msat {
5091
5114
return Err ( ChannelError :: Ignore ( format ! ( "Cannot send less than our next-HTLC minimum - {} msat" ,
5092
5115
available_balances. next_outbound_htlc_minimum_msat) ) ) ;
@@ -5283,8 +5306,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5283
5306
///
5284
5307
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
5285
5308
/// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
5286
- pub fn send_htlc_and_commit < L : Deref > ( & mut self , amount_msat : u64 , payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource , onion_routing_packet : msgs:: OnionPacket , logger : & L ) -> Result < Option < & ChannelMonitorUpdate > , ChannelError > where L :: Target : Logger {
5287
- let send_res = self . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, false , logger) ;
5309
+ pub fn send_htlc_and_commit < F : Deref , L : Deref > ( & mut self , amount_msat : u64 ,
5310
+ payment_hash : PaymentHash , cltv_expiry : u32 , source : HTLCSource ,
5311
+ onion_routing_packet : msgs:: OnionPacket , fee_estimator : & LowerBoundedFeeEstimator < F > ,
5312
+ logger : & L ) -> Result < Option < & ChannelMonitorUpdate > , ChannelError >
5313
+ where F :: Target : FeeEstimator , L :: Target : Logger
5314
+ {
5315
+ let send_res = self . send_htlc ( amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, false , fee_estimator, logger) ;
5288
5316
if let Err ( e) = & send_res { if let ChannelError :: Ignore ( _) = e { } else { debug_assert ! ( false , "Sending cannot trigger channel failure" ) ; } }
5289
5317
match send_res? {
5290
5318
Some ( _) => {
0 commit comments