|
11 | 11 |
|
12 | 12 | //! HWI Signer
|
13 | 13 | //!
|
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 | +//! ``` |
15 | 48 |
|
16 | 49 | use bitcoin::psbt::PartiallySignedTransaction;
|
17 | 50 | use bitcoin::secp256k1::{All, Secp256k1};
|
|
0 commit comments