From 1b0bb23fabe1aec8fac5d2834e0c5b855f9ac457 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 13 Jul 2024 10:09:05 +0300 Subject: [PATCH] Don't fail if bitcoind fee estimation is disabled (#1060) --- src/daemon.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index df22173..c0207b4 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -148,11 +148,15 @@ impl Daemon { } pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result> { - Ok(self - .rpc - .estimate_smart_fee(nblocks, None) - .context("failed to estimate fee")? - .fee_rate) + let res = self.rpc.estimate_smart_fee(nblocks, None); + if let Err(bitcoincore_rpc::Error::JsonRpc(jsonrpc::Error::Rpc(RpcError { + code: -32603, + .. + }))) = res + { + return Ok(None); // don't fail when fee estimation is disabled (e.g. with `-blocksonly=1`) + } + Ok(res.context("failed to estimate fee")?.fee_rate) } pub(crate) fn get_relay_fee(&self) -> Result {