Skip to content

Commit 1b0bb23

Browse files
authored
Don't fail if bitcoind fee estimation is disabled (romanz#1060)
1 parent 785eca6 commit 1b0bb23

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/daemon.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ impl Daemon {
148148
}
149149

150150
pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result<Option<Amount>> {
151-
Ok(self
152-
.rpc
153-
.estimate_smart_fee(nblocks, None)
154-
.context("failed to estimate fee")?
155-
.fee_rate)
151+
let res = self.rpc.estimate_smart_fee(nblocks, None);
152+
if let Err(bitcoincore_rpc::Error::JsonRpc(jsonrpc::Error::Rpc(RpcError {
153+
code: -32603,
154+
..
155+
}))) = res
156+
{
157+
return Ok(None); // don't fail when fee estimation is disabled (e.g. with `-blocksonly=1`)
158+
}
159+
Ok(res.context("failed to estimate fee")?.fee_rate)
156160
}
157161

158162
pub(crate) fn get_relay_fee(&self) -> Result<Amount> {

0 commit comments

Comments
 (0)