diff --git a/bdk-ffi/Cargo.lock b/bdk-ffi/Cargo.lock index a5f2aebe..0281b4fa 100644 --- a/bdk-ffi/Cargo.lock +++ b/bdk-ffi/Cargo.lock @@ -164,9 +164,9 @@ dependencies = [ [[package]] name = "bdk_kyoto" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adeefeb8b453b966761b2b965daeeed163b5ee6984f19daed969d7c90b3ead58" +checksum = "1bb33172976f7fa26115ad6842f7903a2af325544eac6ddf5a17099e3cd9df3c" dependencies = [ "bdk_wallet", "kyoto-cbf", @@ -577,9 +577,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "kyoto-cbf" -version = "0.13.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00ee7b57630516848fe664babc355b07e13a0dd026b8b5795db666908f37883a" +checksum = "805f16bcf1d4738529f230404e7d0ab6e9ecf9e265920c212d446a291a93297e" dependencies = [ "bip324", "bitcoin", diff --git a/bdk-ffi/Cargo.toml b/bdk-ffi/Cargo.toml index 51f579db..30133069 100644 --- a/bdk-ffi/Cargo.toml +++ b/bdk-ffi/Cargo.toml @@ -21,7 +21,7 @@ default = ["uniffi/cli"] bdk_wallet = { version = "2.0.0", features = ["all-keys", "keys-bip39", "rusqlite"] } bdk_esplora = { version = "0.22.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] } bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"] } -bdk_kyoto = { version = "0.13.0" } +bdk_kyoto = { version = "0.13.1" } uniffi = { version = "=0.29.1" } thiserror = "1.0.58" diff --git a/bdk-ffi/src/kyoto.rs b/bdk-ffi/src/kyoto.rs index 852ff2a0..e836ddf5 100644 --- a/bdk-ffi/src/kyoto.rs +++ b/bdk-ffi/src/kyoto.rs @@ -23,6 +23,7 @@ use std::time::Duration; use tokio::sync::Mutex; +use crate::bitcoin::BlockHash; use crate::bitcoin::Transaction; use crate::error::{CbfBuilderError, CbfError}; use crate::types::Update; @@ -340,6 +341,27 @@ impl CbfClient { .map(|fee| Arc::new(FeeRate(fee))) } + /// Fetch the average fee rate for a block by requesting it from a peer. Not recommend for + /// resource-limited devices. + pub async fn average_fee_rate( + &self, + blockhash: Arc, + ) -> Result, CbfError> { + let fee_rate = self + .sender + .average_fee_rate(blockhash.0) + .await + .map_err(|_| CbfError::NodeStopped)?; + Ok(Arc::new(fee_rate.into())) + } + + /// Add another [`Peer`] to attempt a connection with. + pub fn connect(&self, peer: Peer) -> Result<(), CbfError> { + self.sender + .add_peer(peer) + .map_err(|_| CbfError::NodeStopped) + } + /// Query a Bitcoin DNS seeder using the configured resolver. /// /// This is **not** a generic DNS implementation. Host names are prefixed with a `x849` to filter