Skip to content

Commit

Permalink
Merge bitcoindevkit#1549: fix(example_cli): add bitcoin and rand depe…
Browse files Browse the repository at this point in the history
…ndencies

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
  • Loading branch information
notmandatory committed Aug 14, 2024
2 parents 9695296 + 3675a9e commit e0822d7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,32 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings

build-examples:
name: Build Examples
runs-on: ubuntu-latest
strategy:
matrix:
example-dir:
- example_cli
- example_bitcoind_rpc_polling
- example_electrum
- example_esplora
- wallet_electrum
- wallet_esplora_async
- wallet_esplora_blocking
- wallet_rpc
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Build
working-directory: example-crates/${{ matrix.example-dir }}
run: cargo build
2 changes: 2 additions & 0 deletions example-crates/example_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ edition = "2021"
bdk_chain = { path = "../../crates/chain", features = ["serde", "miniscript"]}
bdk_coin_select = "0.3.0"
bdk_file_store = { path = "../../crates/file_store" }
bitcoin = { version = "0.32.0", features = ["base64"], default-features = false }

anyhow = "1"
clap = { version = "3.2.23", features = ["derive", "env"] }
rand = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
16 changes: 6 additions & 10 deletions example-crates/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ use std::sync::Mutex;
use anyhow::bail;
use anyhow::Context;
use bdk_chain::bitcoin::{
absolute,
address::NetworkUnchecked,
bip32, consensus, constants,
hex::DisplayHex,
relative,
secp256k1::{rand::prelude::*, Secp256k1},
transaction, Address, Amount, Network, NetworkKind, PrivateKey, Psbt, PublicKey, Sequence,
Transaction, TxIn, TxOut,
absolute, address::NetworkUnchecked, bip32, consensus, constants, hex::DisplayHex, relative,
secp256k1::Secp256k1, transaction, Address, Amount, Network, NetworkKind, PrivateKey, Psbt,
PublicKey, Sequence, Transaction, TxIn, TxOut,
};
use bdk_chain::miniscript::{
descriptor::{DescriptorSecretKey, SinglePubKey},
Expand All @@ -37,6 +32,7 @@ use bdk_coin_select::{
};
use bdk_file_store::Store;
use clap::{Parser, Subcommand};
use rand::prelude::*;

pub use anyhow;
pub use clap;
Expand Down Expand Up @@ -675,7 +671,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
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 +713,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 e0822d7

Please sign in to comment.