Skip to content

Commit 1a71eb1

Browse files
Update the hardwaresigner module documentation
Add a little example on how to use the HWISigner, slightly improve the module description
1 parent 0695e9f commit 1a71eb1

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/wallet/hardwaresigner.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,40 @@
1111

1212
//! HWI Signer
1313
//!
14-
//! This module contains a simple implementation of a Custom signer for rust-hwi
14+
//! This module contains HWISigner, an implementation of a [TransactionSigner] to be
15+
//! used with hardware wallets.
16+
//! ```no_run
17+
//! # use bdk::bitcoin::Network;
18+
//! # use bdk::database::MemoryDatabase;
19+
//! # use bdk::signer::SignerOrdering;
20+
//! # use bdk::wallet::hardwaresigner::HWISigner;
21+
//! # use bdk::wallet::AddressIndex::New;
22+
//! # use bdk::{FeeRate, KeychainKind, SignOptions, SyncOptions, Wallet};
23+
//! # use hwi::{types::HWIChain, HWIClient};
24+
//! # use std::sync::Arc;
25+
//! #
26+
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
27+
//! let devices = HWIClient::enumerate()?;
28+
//! let first_device = devices.first().expect("No devices found!");
29+
//! let custom_signer = HWISigner::from_device(first_device, HWIChain::Test)?;
30+
//!
31+
//! # let mut wallet = Wallet::new(
32+
//! # "",
33+
//! # None,
34+
//! # Network::Testnet,
35+
//! # MemoryDatabase::default(),
36+
//! # )?;
37+
//! #
38+
//! // Adding the hardware signer to the BDK wallet
39+
//! wallet.add_signer(
40+
//! KeychainKind::External,
41+
//! SignerOrdering(200),
42+
//! Arc::new(custom_signer),
43+
//! );
44+
//!
45+
//! # Ok(())
46+
//! # }
47+
//! ```
1548
1649
use bitcoin::psbt::PartiallySignedTransaction;
1750
use bitcoin::secp256k1::{All, Secp256k1};

0 commit comments

Comments
 (0)