From: Leonardo Lima Date: Fri, 16 Aug 2024 00:41:29 +0000 (-0300) Subject: refactor(wallet)!: remove dangling unused `hardwaresigner.rs` file X-Git-Tag: v1.0.0-beta.3~4^2~3 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.DecoderReader.html?a=commitdiff_plain;h=43257cfca6c8c2a3d5dc2b78da455ff9f16da5bd;p=bdk refactor(wallet)!: remove dangling unused `hardwaresigner.rs` file It seems this file was left out on the previous migration from hardware signers from `bdk_wallet` crate to the `bdk_hwi`, but it should've been removed. --- diff --git a/crates/wallet/src/wallet/hardwaresigner.rs b/crates/wallet/src/wallet/hardwaresigner.rs deleted file mode 100644 index 3ec8d9a5..00000000 --- a/crates/wallet/src/wallet/hardwaresigner.rs +++ /dev/null @@ -1,94 +0,0 @@ -// Bitcoin Dev Kit -// Written in 2020 by Alekos Filini -// -// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers -// -// This file is licensed under the Apache License, Version 2.0 or the MIT license -// , at your option. -// You may not use this file except in accordance with one or both of these -// licenses. - -//! HWI Signer -//! -//! This module contains HWISigner, an implementation of a [TransactionSigner] to be -//! used with hardware wallets. -//! ```no_run -//! # use bdk_wallet::bitcoin::Network; -//! # use bdk_wallet::signer::SignerOrdering; -//! # use bdk_wallet::hardwaresigner::HWISigner; -//! # use bdk_wallet::AddressIndex::New; -//! # use bdk_wallet::{CreateParams, KeychainKind, SignOptions}; -//! # use hwi::HWIClient; -//! # use std::sync::Arc; -//! # -//! # fn main() -> Result<(), Box> { -//! 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 = CreateParams::new("", "", 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(()) -//! # } -//! ``` - -use bitcoin::bip32::Fingerprint; -use bitcoin::secp256k1::{All, Secp256k1}; -use bitcoin::Psbt; - -use hwi::error::Error; -use hwi::types::{HWIChain, HWIDevice}; -use hwi::HWIClient; - -use crate::signer::{SignerCommon, SignerError, SignerId, TransactionSigner}; - -#[derive(Debug)] -/// Custom signer for Hardware Wallets -/// -/// This ignores `sign_options` and leaves the decisions up to the hardware wallet. -pub struct HWISigner { - fingerprint: Fingerprint, - client: HWIClient, -} - -impl HWISigner { - /// Create a instance from the specified device and chain - pub fn from_device(device: &HWIDevice, chain: HWIChain) -> Result { - let client = HWIClient::get_client(device, false, chain)?; - Ok(HWISigner { - fingerprint: device.fingerprint, - client, - }) - } -} - -impl SignerCommon for HWISigner { - fn id(&self, _secp: &Secp256k1) -> SignerId { - SignerId::Fingerprint(self.fingerprint) - } -} - -/// This implementation ignores `sign_options` -impl TransactionSigner for HWISigner { - fn sign_transaction( - &self, - psbt: &mut Psbt, - _sign_options: &crate::SignOptions, - _secp: &crate::wallet::utils::SecpCtx, - ) -> Result<(), SignerError> { - psbt.combine(self.client.sign_tx(psbt)?.psbt) - .expect("Failed to combine HW signed psbt with passed PSBT"); - Ok(()) - } -}