From 083843a94a083faa4b5cf2a914a26d09e2e426be Mon Sep 17 00:00:00 2001 From: Sosthene Date: Sat, 18 May 2024 16:33:25 +0200 Subject: [PATCH] [bug] estimate_fee --- src/daemon.rs | 12 ++++++++---- src/main.rs | 3 +-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index 4e702e0..d3beb46 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -166,12 +166,16 @@ impl Daemon { Ok(Self { rpc }) } - pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result> { - Ok(self + pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result { + let res = self .rpc .estimate_smart_fee(nblocks, None) - .context("failed to estimate fee")? - .fee_rate) + .context("failed to estimate fee")?; + if res.errors.is_some() { + Err(Error::msg(serde_json::to_string(&res.errors.unwrap())?)) + } else { + Ok(res.fee_rate.unwrap()) + } } pub(crate) fn get_relay_fee(&self) -> Result { diff --git a/src/main.rs b/src/main.rs index 2a61286..42dfcd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -207,8 +207,7 @@ fn faucet_send( let fee_estimate = shared_daemon .lock_anyhow()? .estimate_fee(6) - .unwrap_or(Some(Amount::from_sat(1000))) - .unwrap() + .unwrap_or(Amount::from_sat(1000)) .checked_div(1000) .unwrap();