1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Don't fail if bitcoind fee estimation is disabled (#1060)

This commit is contained in:
Roman Zeyde 2024-07-13 10:09:05 +03:00 committed by GitHub
parent 785eca68ff
commit 1b0bb23fab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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> {