Skip to content

Commit 2cb6433

Browse files
authored
feat(kyoto): add avg feerate and connect, bump version
1 parent 65cd4cd commit 2cb6433

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

bdk-ffi/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bdk-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ default = ["uniffi/cli"]
2121
bdk_wallet = { version = "2.0.0", features = ["all-keys", "keys-bip39", "rusqlite"] }
2222
bdk_esplora = { version = "0.22.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
2323
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"] }
24-
bdk_kyoto = { version = "0.13.0" }
24+
bdk_kyoto = { version = "0.13.1" }
2525

2626
uniffi = { version = "=0.29.1" }
2727
thiserror = "1.0.58"

bdk-ffi/src/kyoto.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::time::Duration;
2323

2424
use tokio::sync::Mutex;
2525

26+
use crate::bitcoin::BlockHash;
2627
use crate::bitcoin::Transaction;
2728
use crate::error::{CbfBuilderError, CbfError};
2829
use crate::types::Update;
@@ -340,6 +341,27 @@ impl CbfClient {
340341
.map(|fee| Arc::new(FeeRate(fee)))
341342
}
342343

344+
/// Fetch the average fee rate for a block by requesting it from a peer. Not recommend for
345+
/// resource-limited devices.
346+
pub async fn average_fee_rate(
347+
&self,
348+
blockhash: Arc<BlockHash>,
349+
) -> Result<Arc<FeeRate>, CbfError> {
350+
let fee_rate = self
351+
.sender
352+
.average_fee_rate(blockhash.0)
353+
.await
354+
.map_err(|_| CbfError::NodeStopped)?;
355+
Ok(Arc::new(fee_rate.into()))
356+
}
357+
358+
/// Add another [`Peer`] to attempt a connection with.
359+
pub fn connect(&self, peer: Peer) -> Result<(), CbfError> {
360+
self.sender
361+
.add_peer(peer)
362+
.map_err(|_| CbfError::NodeStopped)
363+
}
364+
343365
/// Query a Bitcoin DNS seeder using the configured resolver.
344366
///
345367
/// This is **not** a generic DNS implementation. Host names are prefixed with a `x849` to filter

0 commit comments

Comments
 (0)