Skip to content

Commit e0822d7

Browse files
committed
Merge #1549: fix(example_cli): add bitcoin and rand dependencies
3675a9e ci: add job to build example-crates independently (Steve Myers) 1adf63c fix(example_cli): add bitcoin and rand dependencies (Steve Myers) Pull request description: ### Description Fix building `example_cli` by adding the bitcoin and rand dependencies so it, and the crates that depend on it, can be built independently and not only from the workspace. ### Notes to the reviewers I also added the build-examples CI job to verify we can build examples individually. ### Changelog notice None. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: ValuedMammal: ACK 3675a9e storopoli: ACK 3675a9e Tree-SHA512: c88fdf6cde72959c88c9f4563834824c573afedb1e5136b0f902d919b42b0de18424fb0d05f275c63a0c05da8062dc53ad5825bdc8dc4b12441890e1b799378b
2 parents 9695296 + 3675a9e commit e0822d7

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

.github/workflows/cont_integration.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,32 @@ jobs:
130130
with:
131131
token: ${{ secrets.GITHUB_TOKEN }}
132132
args: --all-features --all-targets -- -D warnings
133+
134+
build-examples:
135+
name: Build Examples
136+
runs-on: ubuntu-latest
137+
strategy:
138+
matrix:
139+
example-dir:
140+
- example_cli
141+
- example_bitcoind_rpc_polling
142+
- example_electrum
143+
- example_esplora
144+
- wallet_electrum
145+
- wallet_esplora_async
146+
- wallet_esplora_blocking
147+
- wallet_rpc
148+
steps:
149+
- name: checkout
150+
uses: actions/checkout@v2
151+
- name: Install Rust toolchain
152+
uses: actions-rs/toolchain@v1
153+
with:
154+
toolchain: stable
155+
override: true
156+
profile: minimal
157+
- name: Rust Cache
158+
uses: Swatinem/[email protected]
159+
- name: Build
160+
working-directory: example-crates/${{ matrix.example-dir }}
161+
run: cargo build

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)