Skip to content

Commit

Permalink
refactor(signer)!: add signer behind a non-default feature
Browse files Browse the repository at this point in the history
  • Loading branch information
oleonardolima committed Aug 21, 2024
1 parent b25168a commit 7c7adf5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ jobs:
matrix:
rust:
- version: stable # STABLE
features: miniscript
- version: 1.63.0 # MSRV
features: miniscript
features:
- miniscript
- signer
emulator:
- name: trezor
- name: ledger
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
- name: Update toolchain
run: rustup update
- name: Test
run: cargo test --features ${{ matrix.rust.features }}
run: cargo test --features ${{ matrix.features }}
- name: Wipe
run: cargo test test_wipe_device -- --ignored
test-readme-examples:
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bdk_wallet = { version = "1.0.0-beta.1" }
bitcoin = { version = "0.32", features = ["serde", "base64"] }
pyo3 = { version = "0.21.2", features = ["auto-initialize"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1.0" }

bdk_wallet = { version = "1.0.0-beta.1", optional = true }
miniscript = { version = "12.0", features = ["serde"], optional = true }

[dev-dependencies]
serial_test = "0.6.0"

[features]
doctest = []
signer = ["dep:bdk_wallet"]
miniscript = ["dep:miniscript"]
34 changes: 20 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,57 @@
//! ```
//!
//! # HWISigner Example:
//! ## Add custom HWI signer to [`bdk_wallet`]
//! ## Add custom [`HWISigner`] to [`Wallet`]
//! ```no_run
//! # use bdk_wallet::bitcoin::Network;
//! # use bdk_wallet::descriptor::Descriptor;
//! # use bdk_wallet::signer::SignerOrdering;
//! # use hwi::{HWIClient, HWISigner};
//! # use bdk_wallet::{KeychainKind, SignOptions, Wallet};
//! # use std::sync::Arc;
//! # use std::str::FromStr;
//! #
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(feature = "signer")]
//! # {
//! use bdk_wallet::bitcoin::Network;
//! use bdk_wallet::descriptor::Descriptor;
//! use bdk_wallet::signer::SignerOrdering;
//! use bdk_wallet::{KeychainKind, SignOptions, Wallet};
//! use hwi::{HWIClient, HWISigner};
//! use std::sync::Arc;
//! use std::str::FromStr;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut devices = HWIClient::enumerate()?;
//! if devices.is_empty() {
//! panic!("No devices found!");
//! }
//! let first_device = devices.remove(0)?;
//! let custom_signer = HWISigner::from_device(&first_device, Network::Testnet.into())?;
//!
//! # let mut wallet = Wallet::create("", "").network(Network::Testnet).create_wallet_no_persist()?;
//! #
//! let mut wallet = Wallet::create("", "").network(Network::Testnet).create_wallet_no_persist()?;
//!
//! // Adding the hardware signer to the BDK wallet
//! wallet.add_signer(
//! KeychainKind::External,
//! SignerOrdering(200),
//! Arc::new(custom_signer),
//! );
//!
//! # Ok(())
//! Ok(())
//! }
//! # }
//! ```
//!
//! [`TransactionSigner`]: bdk_wallet::signer::TransactionSigner
//! [`TransactionSigner`]: https://docs.rs/bdk_wallet/latest/bdk_wallet/signer/trait.TransactionSigner.html
//! [`Wallet`]: https://docs.rs/bdk_wallet/1.0.0-beta.1/bdk_wallet/struct.Wallet.html
#[cfg(test)]
#[macro_use]
extern crate serial_test;
extern crate core;

pub use interface::HWIClient;
#[cfg(feature = "signer")]
pub use signer::HWISigner;

#[cfg(feature = "doctest")]
pub mod doctest;
pub mod error;
pub mod interface;
#[cfg(feature = "signer")]
pub mod signer;
pub mod types;

Expand Down

0 comments on commit 7c7adf5

Please sign in to comment.