From 1a71eb1f4736651ad82e0abd64792b6cc7b16c20 Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Wed, 12 Oct 2022 14:24:29 +0100 Subject: [PATCH] Update the hardwaresigner module documentation Add a little example on how to use the HWISigner, slightly improve the module description --- src/wallet/hardwaresigner.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/wallet/hardwaresigner.rs b/src/wallet/hardwaresigner.rs index 7e4f74bc..58246392 100644 --- a/src/wallet/hardwaresigner.rs +++ b/src/wallet/hardwaresigner.rs @@ -11,7 +11,40 @@ //! HWI Signer //! -//! This module contains a simple implementation of a Custom signer for rust-hwi +//! This module contains HWISigner, an implementation of a [TransactionSigner] to be +//! used with hardware wallets. +//! ```no_run +//! # use bdk::bitcoin::Network; +//! # use bdk::database::MemoryDatabase; +//! # use bdk::signer::SignerOrdering; +//! # use bdk::wallet::hardwaresigner::HWISigner; +//! # use bdk::wallet::AddressIndex::New; +//! # use bdk::{FeeRate, KeychainKind, SignOptions, SyncOptions, Wallet}; +//! # use hwi::{types::HWIChain, HWIClient}; +//! # use std::sync::Arc; +//! # +//! # fn main() -> Result<(), Box> { +//! let devices = HWIClient::enumerate()?; +//! let first_device = devices.first().expect("No devices found!"); +//! let custom_signer = HWISigner::from_device(first_device, HWIChain::Test)?; +//! +//! # let mut wallet = Wallet::new( +//! # "", +//! # None, +//! # Network::Testnet, +//! # MemoryDatabase::default(), +//! # )?; +//! # +//! // Adding the hardware signer to the BDK wallet +//! wallet.add_signer( +//! KeychainKind::External, +//! SignerOrdering(200), +//! Arc::new(custom_signer), +//! ); +//! +//! # Ok(()) +//! # } +//! ``` use bitcoin::psbt::PartiallySignedTransaction; use bitcoin::secp256k1::{All, Secp256k1};