Skip to content

Commit

Permalink
Don't fail if bitcoind fee estimation is disabled (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Jul 13, 2024
1 parent 785eca6 commit 1b0bb23
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ impl Daemon {
}

pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result<Option<Amount>> {
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<Amount> {
Expand Down

0 comments on commit 1b0bb23

Please sign in to comment.