[bug] estimate_fee

This commit is contained in:
Sosthene 2024-05-18 16:33:25 +02:00
parent 4455c76663
commit 083843a94a
2 changed files with 9 additions and 6 deletions

View File

@ -166,12 +166,16 @@ impl Daemon {
Ok(Self { rpc }) Ok(Self { rpc })
} }
pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result<Option<Amount>> { pub(crate) fn estimate_fee(&self, nblocks: u16) -> Result<Amount> {
Ok(self let res = self
.rpc .rpc
.estimate_smart_fee(nblocks, None) .estimate_smart_fee(nblocks, None)
.context("failed to estimate fee")? .context("failed to estimate fee")?;
.fee_rate) 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<Amount> { pub(crate) fn get_relay_fee(&self) -> Result<Amount> {

View File

@ -207,8 +207,7 @@ fn faucet_send(
let fee_estimate = shared_daemon let fee_estimate = shared_daemon
.lock_anyhow()? .lock_anyhow()?
.estimate_fee(6) .estimate_fee(6)
.unwrap_or(Some(Amount::from_sat(1000))) .unwrap_or(Amount::from_sat(1000))
.unwrap()
.checked_div(1000) .checked_div(1000)
.unwrap(); .unwrap();