Skip to content

Commit

Permalink
chain: add base64 and rand-std features
Browse files Browse the repository at this point in the history
The new chain features are required to build example_cli and dependent crates
independently of the bdk repo eworkspace.
  • Loading branch information
notmandatory committed Aug 12, 2024
1 parent caef3f4 commit 6b6b7ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ proptest = "1.2.0"
default = ["std", "miniscript"]
std = ["bitcoin/std", "miniscript?/std"]
serde = ["dep:serde", "bitcoin/serde", "miniscript?/serde"]
base64 = ["bitcoin/base64"]
rand-std = ["bitcoin/rand-std"]
rusqlite = ["std", "dep:rusqlite", "serde", "serde_json"]
2 changes: 1 addition & 1 deletion example-crates/example_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bdk_chain = { path = "../../crates/chain", features = ["serde", "miniscript"]}
bdk_chain = { path = "../../crates/chain", features = ["serde", "miniscript", "base64", "rand-std"]}
bdk_coin_select = "0.3.0"
bdk_file_store = { path = "../../crates/file_store" }

Expand Down
6 changes: 3 additions & 3 deletions example-crates/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,15 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
// print base64 encoded psbt
let fee = psbt.fee()?.to_sat();
let mut obj = serde_json::Map::new();
obj.insert("psbt".to_string(), json!(psbt.to_string()));
obj.insert("psbt".to_string(), json!(psbt));
obj.insert("fee".to_string(), json!(fee));
println!("{}", serde_json::to_string_pretty(&obj)?);
};

Ok(())
}
PsbtCmd::Sign { psbt, descriptor } => {
let mut psbt = Psbt::from_str(&psbt.unwrap_or_default())?;
let mut psbt = Psbt::from_str(psbt.unwrap_or_default().as_str())?;

let desc_str = match descriptor {
Some(s) => s,
Expand Down Expand Up @@ -717,7 +717,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
chain_specific,
psbt,
} => {
let mut psbt = Psbt::from_str(&psbt)?;
let mut psbt = Psbt::from_str(&psbt.as_str())?;
psbt.finalize_mut(&Secp256k1::new())
.map_err(|errors| anyhow::anyhow!("failed to finalize PSBT {errors:?}"))?;

Expand Down

0 comments on commit 6b6b7ab

Please sign in to comment.