Skip to content

Commit a2a1c7c

Browse files
committed
f - fee_estimator clean-up
1 parent 32c50ce commit a2a1c7c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ fn build_with_store_internal(
17181718
wallet,
17191719
chain_source,
17201720
tx_broadcaster,
1721+
fee_estimator,
17211722
event_queue,
17221723
channel_manager,
17231724
chain_monitor,

src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub use error::Error as NodeError;
122122
use error::Error;
123123
pub use event::Event;
124124
use event::{EventHandler, EventQueue};
125+
use fee_estimator::{ConfirmationTarget, FeeEstimator, OnchainFeeEstimator};
125126
#[cfg(feature = "uniffi")]
126127
use ffi::*;
127128
use gossip::GossipSource;
@@ -176,6 +177,7 @@ pub struct Node {
176177
wallet: Arc<Wallet>,
177178
chain_source: Arc<ChainSource>,
178179
tx_broadcaster: Arc<Broadcaster>,
180+
fee_estimator: Arc<OnchainFeeEstimator>,
179181
event_queue: Arc<EventQueue<Arc<Logger>>>,
180182
channel_manager: Arc<ChannelManager>,
181183
chain_monitor: Arc<ChainMonitor>,
@@ -1247,7 +1249,7 @@ impl Node {
12471249
.to_p2wsh(),
12481250
};
12491251

1250-
let fee_rate = self.wallet.estimate_channel_funding_fee_rate();
1252+
let fee_rate = self.fee_estimator.estimate_fee_rate(ConfirmationTarget::ChannelFunding);
12511253

12521254
let inputs = self
12531255
.wallet
@@ -1266,7 +1268,13 @@ impl Node {
12661268
change_script: None,
12671269
};
12681270

1269-
let funding_feerate_per_kw = fee_rate.to_sat_per_kwu().try_into().unwrap_or(u32::MAX);
1271+
let funding_feerate_per_kw: u32 = match fee_rate.to_sat_per_kwu().try_into() {
1272+
Ok(fee_rate) => fee_rate,
1273+
Err(_) => {
1274+
debug_assert!(false);
1275+
fee_estimator::get_fallback_rate_for_target(ConfirmationTarget::ChannelFunding)
1276+
},
1277+
};
12701278

12711279
self.channel_manager
12721280
.splice_channel(

src/wallet/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ impl Wallet {
275275
Ok(tx)
276276
}
277277

278-
pub(crate) fn estimate_channel_funding_fee_rate(&self) -> FeeRate {
279-
self.fee_estimator.estimate_fee_rate(ConfirmationTarget::ChannelFunding)
280-
}
281-
282278
pub(crate) fn get_new_address(&self) -> Result<bitcoin::Address, Error> {
283279
let mut locked_wallet = self.inner.lock().unwrap();
284280
let mut locked_persister = self.persister.lock().unwrap();

0 commit comments

Comments
 (0)