Skip to content

Commit 70617f9

Browse files
committed
Update bdk_kyoto to 0.15.1
Checkpoints were removed from Kyoto to minimize trust in the library and reduce maintence burden. As such, there is no longer the ability to "skip blocks", at least on test networks. Mainnet offers two checkpoints, segwit and taproot activation, but these are included from genesis on test networks. Broadcasting a transaction now awaits for the transaction to be gossiped, simplifying the logic here.
1 parent f100d65 commit 70617f9

File tree

5 files changed

+36
-65
lines changed

5 files changed

+36
-65
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cli-table = "0.5.0"
2626
bdk_bitcoind_rpc = { version = "0.21.0", features = ["std"], optional = true }
2727
bdk_electrum = { version = "0.23.0", optional = true }
2828
bdk_esplora = { version = "0.22.1", features = ["async-https", "tokio"], optional = true }
29-
bdk_kyoto = { version = "0.13.1", optional = true }
29+
bdk_kyoto = { version = "0.15.1", optional = true }
3030
bdk_redb = { version = "0.1.0", optional = true }
3131
shlex = { version = "1.3.0", optional = true }
3232
tracing = "0.1.41"

src/commands.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ pub struct CompactFilterOpts {
247247
/// Sets the number of parallel node connections.
248248
#[clap(name = "CONNECTIONS", long = "cbf-conn-count", default_value = "2", value_parser = value_parser!(u8).range(1..=15))]
249249
pub conn_count: u8,
250-
251-
/// Optionally skip initial `skip_blocks` blocks.
252-
#[clap(env = "SKIP_BLOCKS", short = 'k', long = "cbf-skip-blocks")]
253-
pub skip_blocks: Option<u32>,
254250
}
255251

256252
/// Wallet subcommands that can be issued without a blockchain backend.

src/handlers.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use std::sync::Arc;
5858
#[cfg(feature = "electrum")]
5959
use crate::utils::BlockchainClient::Electrum;
6060
#[cfg(feature = "cbf")]
61-
use bdk_kyoto::{Info, LightClient};
61+
use bdk_kyoto::LightClient;
6262
#[cfg(feature = "compiler")]
6363
use bdk_wallet::bitcoin::XOnlyPublicKey;
6464
use bdk_wallet::bitcoin::base64::prelude::*;
@@ -809,7 +809,6 @@ pub(crate) async fn handle_online_wallet_subcommand(
809809
KyotoClient { client } => {
810810
let LightClient {
811811
requester,
812-
mut log_subscriber,
813812
mut info_subscriber,
814813
mut warning_subscriber,
815814
update_subscriber: _,
@@ -823,9 +822,9 @@ pub(crate) async fn handle_online_wallet_subcommand(
823822
tokio::task::spawn(async move { node.run().await });
824823
tokio::task::spawn(async move {
825824
select! {
826-
log = log_subscriber.recv() => {
827-
if let Some(log) = log {
828-
tracing::info!("{log}");
825+
info = info_subscriber.recv() => {
826+
if let Some(info) = info {
827+
tracing::info!("{info}");
829828
}
830829
},
831830
warn = warning_subscriber.recv() => {
@@ -836,29 +835,11 @@ pub(crate) async fn handle_online_wallet_subcommand(
836835
}
837836
});
838837
let txid = tx.compute_txid();
839-
requester
840-
.broadcast_random(tx.clone())
841-
.map_err(|e| Error::Generic(format!("{e}")))?;
842-
tokio::time::timeout(tokio::time::Duration::from_secs(30), async move {
843-
while let Some(info) = info_subscriber.recv().await {
844-
match info {
845-
Info::TxGossiped(wtxid) => {
846-
tracing::info!("Successfully broadcast WTXID: {wtxid}");
847-
break;
848-
}
849-
Info::ConnectionsMet => {
850-
tracing::info!("Rebroadcasting to new connections");
851-
requester.broadcast_random(tx.clone()).unwrap();
852-
}
853-
_ => tracing::info!("{info}"),
854-
}
855-
}
856-
})
857-
.await
858-
.map_err(|_| {
838+
let wtxid = requester.broadcast_random(tx.clone()).await.map_err(|_| {
859839
tracing::warn!("Broadcast was unsuccessful");
860840
Error::Generic("Transaction broadcast timed out after 30 seconds".into())
861841
})?;
842+
tracing::info!("Successfully broadcast WTXID: {wtxid}");
862843
txid
863844
}
864845
};

src/utils.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ use std::path::{Path, PathBuf};
1818
use crate::commands::WalletOpts;
1919
#[cfg(feature = "cbf")]
2020
use bdk_kyoto::{
21-
Info, LightClient, NodeBuilderExt, Receiver,
22-
ScanType::{Recovery, Sync},
23-
UnboundedReceiver, Warning,
24-
builder::NodeBuilder,
21+
BuilderExt, Info, LightClient, Receiver, ScanType::Sync, UnboundedReceiver, Warning,
22+
builder::Builder,
2523
};
2624
use bdk_wallet::bitcoin::{Address, Network, OutPoint, ScriptBuf};
2725

@@ -195,12 +193,8 @@ pub(crate) fn new_blockchain_client(
195193

196194
#[cfg(feature = "cbf")]
197195
ClientType::Cbf => {
198-
let scan_type = match wallet_opts.compactfilter_opts.skip_blocks {
199-
Some(from_height) => Recovery { from_height },
200-
None => Sync,
201-
};
202-
203-
let builder = NodeBuilder::new(_wallet.network());
196+
let scan_type = Sync;
197+
let builder = Builder::new(_wallet.network());
204198

205199
let client = builder
206200
.required_peers(wallet_opts.compactfilter_opts.conn_count)
@@ -299,17 +293,11 @@ pub(crate) fn new_wallet(network: Network, wallet_opts: &WalletOpts) -> Result<W
299293

300294
#[cfg(feature = "cbf")]
301295
pub async fn trace_logger(
302-
mut log_subscriber: Receiver<String>,
303296
mut info_subcriber: Receiver<Info>,
304297
mut warning_subscriber: UnboundedReceiver<Warning>,
305298
) {
306299
loop {
307300
tokio::select! {
308-
log = log_subscriber.recv() => {
309-
if let Some(log) = log {
310-
tracing::info!("{log}")
311-
}
312-
}
313301
info = info_subcriber.recv() => {
314302
if let Some(info) = info {
315303
tracing::info!("{info}")
@@ -329,7 +317,6 @@ pub async fn trace_logger(
329317
pub async fn sync_kyoto_client(wallet: &mut Wallet, client: Box<LightClient>) -> Result<(), Error> {
330318
let LightClient {
331319
requester,
332-
log_subscriber,
333320
info_subscriber,
334321
warning_subscriber,
335322
mut update_subscriber,
@@ -341,9 +328,7 @@ pub async fn sync_kyoto_client(wallet: &mut Wallet, client: Box<LightClient>) ->
341328
.map_err(|e| Error::Generic(format!("SetGlobalDefault error: {e}")))?;
342329

343330
tokio::task::spawn(async move { node.run().await });
344-
tokio::task::spawn(async move {
345-
trace_logger(log_subscriber, info_subscriber, warning_subscriber).await
346-
});
331+
tokio::task::spawn(async move { trace_logger(info_subscriber, warning_subscriber).await });
347332

348333
if !requester.is_running() {
349334
tracing::error!("Kyoto node is not running");

0 commit comments

Comments
 (0)