Skip to content

Commit cf305fd

Browse files
committed
chore: update for bdk_wallet 3.1.0 API changes
- bump bdk_wallet to 3.1.0 - replace Network with NetworkKind - replace TxBuilder::include_output_redeem_witness_script with TxBuilder::add_global_xpubs
1 parent 0c5c036 commit cf305fd

10 files changed

Lines changed: 83 additions & 77 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readme = "README.md"
1212
license = "MIT"
1313

1414
[dependencies]
15-
bdk_wallet = { version = "2.4.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
15+
bdk_wallet = { version = "3.1.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
1616
clap = { version = "4.6", features = ["derive","env"] }
1717
clap_complete = "4.6"
1818
dirs = { version = "6.0.0" }
@@ -32,8 +32,8 @@ tap = "1.0.1"
3232
bdk_bitcoind_rpc = { version = "0.22.0", features = ["std"], optional = true }
3333
bdk_electrum = { version = "0.24.0", optional = true }
3434
bdk_esplora = { version = "0.22.2", features = ["async-https", "tokio"], optional = true }
35-
bdk_kyoto = { version = "0.15.4", optional = true }
36-
bdk_redb = { version = "0.1.1", optional = true }
35+
bdk_kyoto = { version = "0.17.0", optional = true }
36+
bdk_redb = { version = "0.2.0", optional = true }
3737
bdk_sp = { version = "0.1.0", optional = true, git = "https://github.com/bitcoindevkit/bdk-sp", tag = "v0.1.0" }
3838
shlex = { version = "1.3.0", optional = true }
3939
payjoin = { version = "0.25.0", features = ["v1", "v2", "io", "_test-utils"], optional = true}

src/client.rs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ use {
2323
};
2424

2525
#[cfg(feature = "cbf")]
26-
use {
27-
crate::utils::trace_logger,
28-
bdk_kyoto::{BuilderExt, LightClient},
29-
};
26+
use {crate::utils::trace_logger, bdk_kyoto::BuilderExt};
3027

3128
#[cfg(any(
3229
feature = "electrum",
@@ -101,14 +98,10 @@ impl BlockchainClient {
10198
#[cfg(feature = "cbf")]
10299
Self::KyotoClient { client } => {
103100
let txid = tx.compute_txid();
104-
let wtxid = client
105-
.requester
106-
.broadcast_random(tx.clone())
107-
.await
108-
.map_err(|_| {
109-
tracing::warn!("Broadcast was unsuccessful");
110-
Error::Generic("Transaction broadcast timed out after 30 seconds".into())
111-
})?;
101+
let wtxid = client.requester.submit_package(tx).await.map_err(|_| {
102+
tracing::warn!("Broadcast was unsuccessful");
103+
Error::Generic("Transaction broadcast timed out after 30 seconds".into())
104+
})?;
112105
tracing::info!("Successfully broadcast WTXID: {wtxid}");
113106
Ok(txid)
114107
}
@@ -205,7 +198,8 @@ impl BlockchainClient {
205198
#[cfg(feature = "cbf")]
206199
pub struct KyotoClientHandle {
207200
pub requester: bdk_kyoto::Requester,
208-
pub update_subscriber: tokio::sync::Mutex<bdk_kyoto::UpdateSubscriber>,
201+
pub update_subscriber:
202+
tokio::sync::Mutex<bdk_kyoto::UpdateSubscriber<bdk_kyoto::wallets::Single>>,
209203
}
210204

211205
#[cfg(any(
@@ -267,21 +261,16 @@ pub(crate) fn new_blockchain_client(
267261
.data_dir(&_datadir)
268262
.build_with_wallet(_wallet, scan_type)?;
269263

270-
let LightClient {
271-
requester,
272-
info_subscriber,
273-
warning_subscriber,
274-
update_subscriber,
275-
node,
276-
} = light_client;
264+
let (client, logging, update_subscriber) = light_client.subscribe();
265+
// `start()` spawns the node's run loop on a tokio task internally.
266+
let requester = client.start().requester();
277267

278268
let subscriber = tracing_subscriber::FmtSubscriber::new();
279269
let _ = tracing::subscriber::set_global_default(subscriber);
280270

281-
tokio::task::spawn(async move { node.run().await });
282-
tokio::task::spawn(
283-
async move { trace_logger(info_subscriber, warning_subscriber).await },
284-
);
271+
tokio::task::spawn(async move {
272+
trace_logger(logging.info_subscriber, logging.warning_subscriber).await
273+
});
285274

286275
BlockchainClient::KyotoClient {
287276
client: Box::new(KyotoClientHandle {

src/handlers/dns/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl AsyncAppCommand<AppContext<OfflineOperations<'_>>> for CreateDnsTxCommand {
127127
tx_builder.set_exact_sequence(Sequence::MAX);
128128
}
129129
if self.offline_signer {
130-
tx_builder.include_output_redeem_witness_script();
130+
tx_builder.add_global_xpubs();
131131
}
132132
if let Some(fee_rate) = self.fee_rate
133133
&& let Some(fee_rate) = FeeRate::from_sat_per_vb(fee_rate as u64)

src/handlers/key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl AppCommand<AppContext<Init>> for GenerateKeyCommand {
5656
.map_err(|_| Error::Generic("Mnemonic generation error".to_string()))?;
5757
let mnemonic = mnemonic.into_key();
5858
let xkey: ExtendedKey = (mnemonic.clone(), self.password.clone()).into_extended_key()?;
59-
let xprv = xkey.into_xprv(ctx.network).ok_or_else(|| {
59+
let xprv = xkey.into_xprv(ctx.network.into()).ok_or_else(|| {
6060
Error::Generic("Privatekey info not found (should not happen)".to_string())
6161
})?;
6262
let fingerprint = xprv.fingerprint(&secp);
@@ -139,7 +139,7 @@ impl AppCommand<AppContext<Init>> for RestoreKeyCommand {
139139

140140
let mnemonic = Mnemonic::parse_in(Language::English, &self.mnemonic)?;
141141
let xkey: ExtendedKey = (mnemonic.clone(), &self.password).0.into_extended_key()?;
142-
let xprv = xkey.into_xprv(ctx.network).ok_or_else(|| {
142+
let xprv = xkey.into_xprv(ctx.network.into()).ok_or_else(|| {
143143
Error::Generic("Privatekey info not found (should not happen)".to_string())
144144
})?;
145145
let fingerprint = xprv.fingerprint(&secp);

src/handlers/offline.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use {
3232
use {
3333
crate::utils::parse_signature_format,
3434
crate::utils::types::MessageResult,
35-
bdk_message_signer::{MessageSigner, MessageProof},
35+
bdk_message_signer::{MessageProof, MessageSigner},
3636
};
3737

3838
impl OfflineWalletSubCommand {
@@ -269,7 +269,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for CreateTxCommand {
269269
}
270270

271271
if self.offline_signer {
272-
tx_builder.include_output_redeem_witness_script();
272+
tx_builder.add_global_xpubs();
273273
}
274274

275275
if let Some(fee_rate) = self.fee_rate
@@ -424,7 +424,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for CreateSpTxCommand {
424424
tx_builder.set_exact_sequence(Sequence::MAX);
425425

426426
if self.offline_signer {
427-
tx_builder.include_output_redeem_witness_script();
427+
tx_builder.add_global_xpubs();
428428
}
429429

430430
if let Some(fee_rate) = self.fee_rate
@@ -586,7 +586,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for BumpFeeCommand {
586586
}
587587

588588
if self.offline_signer {
589-
tx_builder.include_output_redeem_witness_script();
589+
tx_builder.add_global_xpubs();
590590
}
591591

592592
if let Some(utxos) = &self.utxos {

src/utils/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{commands::WalletOpts, config::WalletConfig, error::BDKCliError as Error};
2-
#[cfg(feature = "message_signer")]
3-
use bdk_message_signer::SignatureFormat;
42
#[cfg(feature = "cbf")]
53
use bdk_kyoto::{Info, Receiver, UnboundedReceiver, Warning};
4+
#[cfg(feature = "message_signer")]
5+
use bdk_message_signer::SignatureFormat;
66
#[cfg(feature = "silent-payments")]
77
use bdk_sp::encoding::SilentPaymentCode;
88
use bdk_wallet::bitcoin::{Address, Network, OutPoint, ScriptBuf};
@@ -12,7 +12,7 @@ use bdk_wallet::bitcoin::{Address, Network, OutPoint, ScriptBuf};
1212
feature = "cbf",
1313
feature = "rpc"
1414
))]
15-
use bdk_wallet::{bitcoin::Psbt, event::WalletEvent};
15+
use bdk_wallet::{WalletEvent, bitcoin::Psbt};
1616

1717
use crate::commands::OfflineWalletSubCommand;
1818
use std::{

src/utils/descriptors.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ fn generate_private_descriptors(
6161
let fingerprint = xprv.fingerprint(&secp);
6262

6363
let (external_desc, external_keymap, _) = match desc_type.to_lowercase().as_str() {
64-
"pkh" => Bip44(xprv, KeychainKind::External).build(network)?,
65-
"sh" => Bip49(xprv, KeychainKind::External).build(network)?,
66-
"wpkh" | "wsh" => Bip84(xprv, KeychainKind::External).build(network)?,
67-
"tr" => Bip86(xprv, KeychainKind::External).build(network)?,
64+
"pkh" => Bip44(xprv, KeychainKind::External).build(network.into())?,
65+
"sh" => Bip49(xprv, KeychainKind::External).build(network.into())?,
66+
"wpkh" | "wsh" => Bip84(xprv, KeychainKind::External).build(network.into())?,
67+
"tr" => Bip86(xprv, KeychainKind::External).build(network.into())?,
6868
_ => {
6969
return Err(Error::Generic(format!(
7070
"Unsupported descriptor type: {desc_type}"
@@ -73,10 +73,10 @@ fn generate_private_descriptors(
7373
};
7474

7575
let (internal_desc, internal_keymap, _) = match desc_type.to_lowercase().as_str() {
76-
"pkh" => Bip44(xprv, KeychainKind::Internal).build(network)?,
77-
"sh" => Bip49(xprv, KeychainKind::Internal).build(network)?,
78-
"wpkh" | "wsh" => Bip84(xprv, KeychainKind::Internal).build(network)?,
79-
"tr" => Bip86(xprv, KeychainKind::Internal).build(network)?,
76+
"pkh" => Bip44(xprv, KeychainKind::Internal).build(network.into())?,
77+
"sh" => Bip49(xprv, KeychainKind::Internal).build(network.into())?,
78+
"wpkh" | "wsh" => Bip84(xprv, KeychainKind::Internal).build(network.into())?,
79+
"tr" => Bip86(xprv, KeychainKind::Internal).build(network.into())?,
8080
_ => {
8181
return Err(Error::Generic(format!(
8282
"Unsupported descriptor type: {desc_type}"

tests/integration/offline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ mod test_offline {
151151
.stderr(predicate::str::contains("Invalid"));
152152
}
153153

154-
#[cfg(feature = "bip322")]
154+
#[cfg(feature = "message_signer")]
155155
#[test]
156156
fn test_sign_message_and_verify_message() {
157157
let (cli, mut cmd_init) = setup_wallet_config();
@@ -216,7 +216,7 @@ mod test_offline {
216216
.stdout(predicate::str::contains("\"valid\": true"));
217217
}
218218

219-
#[cfg(feature = "bip322")]
219+
#[cfg(feature = "message_signer")]
220220
#[test]
221221
fn test_verify_message_rejects_tampered_message() {
222222
let (cli, mut cmd_init) = setup_wallet_config();

0 commit comments

Comments
 (0)