Skip to content

Commit 1adf63c

Browse files
committed
fix(example_cli): add bitcoin and rand dependencies
The bitcoin and rand dependencies are required to build examples independently and not from the top level bdk workspace.
1 parent caef3f4 commit 1adf63c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

example-crates/example_cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ edition = "2021"
99
bdk_chain = { path = "../../crates/chain", features = ["serde", "miniscript"]}
1010
bdk_coin_select = "0.3.0"
1111
bdk_file_store = { path = "../../crates/file_store" }
12+
bitcoin = { version = "0.32.0", features = ["base64"], default-features = false }
1213

1314
anyhow = "1"
1415
clap = { version = "3.2.23", features = ["derive", "env"] }
16+
rand = "0.8"
1517
serde = { version = "1", features = ["derive"] }
1618
serde_json = "1.0"

example-crates/example_cli/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@ use std::sync::Mutex;
1010
use anyhow::bail;
1111
use anyhow::Context;
1212
use bdk_chain::bitcoin::{
13-
absolute,
14-
address::NetworkUnchecked,
15-
bip32, consensus, constants,
16-
hex::DisplayHex,
17-
relative,
18-
secp256k1::{rand::prelude::*, Secp256k1},
19-
transaction, Address, Amount, Network, NetworkKind, PrivateKey, Psbt, PublicKey, Sequence,
20-
Transaction, TxIn, TxOut,
13+
absolute, address::NetworkUnchecked, bip32, consensus, constants, hex::DisplayHex, relative,
14+
secp256k1::Secp256k1, transaction, Address, Amount, Network, NetworkKind, PrivateKey, Psbt,
15+
PublicKey, Sequence, Transaction, TxIn, TxOut,
2116
};
2217
use bdk_chain::miniscript::{
2318
descriptor::{DescriptorSecretKey, SinglePubKey},
@@ -37,6 +32,7 @@ use bdk_coin_select::{
3732
};
3833
use bdk_file_store::Store;
3934
use clap::{Parser, Subcommand};
35+
use rand::prelude::*;
4036

4137
pub use anyhow;
4238
pub use clap;
@@ -675,7 +671,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
675671
Ok(())
676672
}
677673
PsbtCmd::Sign { psbt, descriptor } => {
678-
let mut psbt = Psbt::from_str(&psbt.unwrap_or_default())?;
674+
let mut psbt = Psbt::from_str(psbt.unwrap_or_default().as_str())?;
679675

680676
let desc_str = match descriptor {
681677
Some(s) => s,
@@ -717,7 +713,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
717713
chain_specific,
718714
psbt,
719715
} => {
720-
let mut psbt = Psbt::from_str(&psbt)?;
716+
let mut psbt = Psbt::from_str(psbt.as_str())?;
721717
psbt.finalize_mut(&Secp256k1::new())
722718
.map_err(|errors| anyhow::anyhow!("failed to finalize PSBT {errors:?}"))?;
723719

0 commit comments

Comments
 (0)