From: Daniela Brozzoni Date: Wed, 12 Oct 2022 13:24:29 +0000 (+0100) Subject: Update the hardwaresigner module documentation X-Git-Tag: v0.24.0-rc.1~4^2~1 X-Git-Url: http://internal-gitweb-vhost/%22https:/parse/scripts/database/-script/-script-amount/struct.EncoderStringWriter.html?a=commitdiff_plain;h=1a71eb1f4736651ad82e0abd64792b6cc7b16c20;p=bdk Update the hardwaresigner module documentation Add a little example on how to use the HWISigner, slightly improve the module description --- 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};