]> Untitled Git - bdk/commitdiff
refactor(bdk_hwi)!: remove `bdk_hwi`
authorLeonardo Lima <oleonardolima@users.noreply.github.com>
Fri, 16 Aug 2024 00:59:29 +0000 (21:59 -0300)
committerSteve Myers <steve@notmandatory.org>
Wed, 11 Sep 2024 14:47:53 +0000 (09:47 -0500)
- removes `bdk_hwi` crate, as `HWISigner`'s being moved to
rust-hwi.
- please refer to: https://github.com/bitcoindevkit/rust-hwi/pull/104

Cargo.toml
crates/hwi/Cargo.toml [deleted file]
crates/hwi/README.md [deleted file]
crates/hwi/src/lib.rs [deleted file]
crates/hwi/src/signer.rs [deleted file]

index 26ca48b767a6645a47845ab818cc967978205d78..a6e6eb6e609a7d63643431c3f28c66db826b8e38 100644 (file)
@@ -8,7 +8,6 @@ members = [
     "crates/electrum",
     "crates/esplora",
     "crates/bitcoind_rpc",
-    "crates/hwi",
     "crates/testenv",
     "example-crates/example_cli",
     "example-crates/example_electrum",
diff --git a/crates/hwi/Cargo.toml b/crates/hwi/Cargo.toml
deleted file mode 100644 (file)
index fdb1466..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "bdk_hwi"
-version = "0.5.0"
-edition = "2021"
-homepage = "https://bitcoindevkit.org"
-repository = "https://github.com/bitcoindevkit/bdk"
-description = "Utilities to use bdk with hardware wallets"
-license = "MIT OR Apache-2.0"
-readme = "README.md"
-
-[lints]
-workspace = true
-
-[dependencies]
-bdk_wallet = { path = "../wallet", version = "1.0.0-beta.2" }
-hwi = { version = "0.9.0", features = [ "miniscript" ] }
diff --git a/crates/hwi/README.md b/crates/hwi/README.md
deleted file mode 100644 (file)
index f31601b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# BDK HWI Signer
-
-This crate contains `HWISigner`, an implementation of a `TransactionSigner` to be used with hardware wallets.
\ No newline at end of file
diff --git a/crates/hwi/src/lib.rs b/crates/hwi/src/lib.rs
deleted file mode 100644 (file)
index 7bb7e4c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//! HWI Signer
-//!
-//! This crate contains HWISigner, an implementation of a [`TransactionSigner`] to be
-//! used with hardware wallets.
-//! ```no_run
-//! # use bdk_wallet::bitcoin::Network;
-//! # use bdk_wallet::descriptor::Descriptor;
-//! # use bdk_wallet::signer::SignerOrdering;
-//! # use bdk_hwi::HWISigner;
-//! # use bdk_wallet::{KeychainKind, SignOptions, Wallet};
-//! # use hwi::HWIClient;
-//! # use std::sync::Arc;
-//! # use std::str::FromStr;
-//! #
-//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
-//! 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 = Wallet::create("", "").network(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(())
-//! # }
-//! ```
-//!
-//! [`TransactionSigner`]: bdk_wallet::signer::TransactionSigner
-
-mod signer;
-pub use signer::*;
diff --git a/crates/hwi/src/signer.rs b/crates/hwi/src/signer.rs
deleted file mode 100644 (file)
index f1b569e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-use bdk_wallet::bitcoin::bip32::Fingerprint;
-use bdk_wallet::bitcoin::secp256k1::{All, Secp256k1};
-use bdk_wallet::bitcoin::Psbt;
-
-use hwi::error::Error;
-use hwi::types::{HWIChain, HWIDevice};
-use hwi::HWIClient;
-
-use bdk_wallet::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<HWISigner, Error> {
-        let client = HWIClient::get_client(device, false, chain)?;
-        Ok(HWISigner {
-            fingerprint: device.fingerprint,
-            client,
-        })
-    }
-}
-
-impl SignerCommon for HWISigner {
-    fn id(&self, _secp: &Secp256k1<All>) -> SignerId {
-        SignerId::Fingerprint(self.fingerprint)
-    }
-}
-
-impl TransactionSigner for HWISigner {
-    fn sign_transaction(
-        &self,
-        psbt: &mut Psbt,
-        _sign_options: &bdk_wallet::SignOptions,
-        _secp: &Secp256k1<All>,
-    ) -> Result<(), SignerError> {
-        psbt.combine(
-            self.client
-                .sign_tx(psbt)
-                .map_err(|e| {
-                    SignerError::External(format!("While signing with hardware wallet: {}", e))
-                })?
-                .psbt,
-        )
-        .expect("Failed to combine HW signed psbt with passed PSBT");
-        Ok(())
-    }
-}
-
-// TODO: re-enable this once we have the `get_funded_wallet` test util
-// #[cfg(test)]
-// mod tests {
-//     #[test]
-//     fn test_hardware_signer() {
-//         use std::sync::Arc;
-//
-//         use bdk_wallet::tests::get_funded_wallet;
-//         use bdk_wallet::signer::SignerOrdering;
-//         use bdk_wallet::bitcoin::Network;
-//         use crate::HWISigner;
-//         use hwi::HWIClient;
-//
-//         let mut devices = HWIClient::enumerate().unwrap();
-//         if devices.is_empty() {
-//             panic!("No devices found!");
-//         }
-//         let device = devices.remove(0).unwrap();
-//         let client = HWIClient::get_client(&device, true, Network::Regtest.into()).unwrap();
-//         let descriptors = client.get_descriptors::<String>(None).unwrap();
-//         let custom_signer = HWISigner::from_device(&device, Network::Regtest.into()).unwrap();
-//
-//         let (mut wallet, _) = get_funded_wallet(&descriptors.internal[0]);
-//         wallet.add_signer(
-//             bdk_wallet::KeychainKind::External,
-//             SignerOrdering(200),
-//             Arc::new(custom_signer),
-//         );
-//
-//         let addr = wallet.get_address(bdk_wallet::AddressIndex::LastUnused);
-//         let mut builder = wallet.build_tx();
-//         builder.drain_to(addr.script_pubkey()).drain_wallet();
-//         let (mut psbt, _) = builder.finish().unwrap();
-//
-//         let finalized = wallet.sign(&mut psbt, Default::default()).unwrap();
-//         assert!(finalized);
-//     }
-// }