[wallet] Add a type convert fee units, add Wallet::estimate_fee()

This commit is contained in:
Alekos Filini
2020-08-07 11:23:01 +02:00
parent 5f80950971
commit 08792b2fcd
8 changed files with 115 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ use self::utils::{ELSGetHistoryRes, ELSListUnspentRes, ElectrumLikeSync};
use super::*;
use crate::database::{BatchDatabase, DatabaseUtils};
use crate::error::Error;
use crate::FeeRate;
pub struct ElectrumBlockchain(Option<Client>);
@@ -77,6 +78,15 @@ impl OnlineBlockchain for ElectrumBlockchain {
.block_headers_subscribe()
.map(|data| data.height)?)
}
fn estimate_fee(&self, target: usize) -> Result<FeeRate, Error> {
Ok(FeeRate::from_btc_per_kvb(
self.0
.as_ref()
.ok_or(Error::OfflineClient)?
.estimate_fee(target)? as f32,
))
}
}
impl ElectrumLikeSync for Client {