diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 5a91de04e..613a015d8 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -27,17 +27,6 @@ jobs: uses: Swatinem/rust-cache@v2.2.1 - name: Install grcov run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi - # TODO: re-enable the hwi tests - - name: Build simulator image - run: docker build -t hwi/ledger_emulator ./ci -f ci/Dockerfile.ledger - - name: Run simulator image - run: docker run --name simulator --network=host hwi/ledger_emulator & - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Install python dependencies - run: pip install hwi==2.1.1 protobuf==3.20.1 - name: Test run: cargo test --all-features - name: Make coverage directory diff --git a/Cargo.toml b/Cargo.toml index 26ca48b76..a6e6eb6e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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/ci/Dockerfile.ledger b/ci/Dockerfile.ledger deleted file mode 100644 index fb4c6bc41..000000000 --- a/ci/Dockerfile.ledger +++ /dev/null @@ -1,9 +0,0 @@ -# Taken from bitcoindevkit/rust-hwi -FROM ghcr.io/ledgerhq/speculos - -RUN apt-get update -RUN apt-get install wget -y -RUN wget "https://github.com/LedgerHQ/speculos/blob/master/apps/nanos%23btc%232.1%231c8db8da.elf?raw=true" -O /speculos/btc.elf -ADD automation.json /speculos/automation.json - -ENTRYPOINT ["python", "./speculos.py", "--automation", "file:automation.json", "--model", "nanos", "--display", "headless", "--vnc-port", "41000", "btc.elf"] diff --git a/ci/automation.json b/ci/automation.json deleted file mode 100644 index 9de2f60e6..000000000 --- a/ci/automation.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": 1, - "rules": [ - { - "regexp": "Address \\(\\d/\\d\\)|Message hash \\(\\d/\\d\\)|Confirm|Fees|Review|Amount", - "actions": [ - [ "button", 2, true ], - [ "button", 2, false ] - ] - }, - { - "text": "Sign", - "conditions": [ - [ "seen", false ] - ], - "actions": [ - [ "button", 2, true ], - [ "button", 2, false ], - [ "setbool", "seen", true ] - ] - }, - { - "regexp": "Approve|Sign|Accept", - "actions": [ - [ "button", 3, true ], - [ "button", 3, false ] - ] - } - ] -} diff --git a/crates/hwi/Cargo.toml b/crates/hwi/Cargo.toml deleted file mode 100644 index fdb146626..000000000 --- a/crates/hwi/Cargo.toml +++ /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 index f31601b97..000000000 --- a/crates/hwi/README.md +++ /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 index 7bb7e4caf..000000000 --- a/crates/hwi/src/lib.rs +++ /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> { -//! 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 index f1b569e35..000000000 --- a/crates/hwi/src/signer.rs +++ /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 { - 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) - } -} - -impl TransactionSigner for HWISigner { - fn sign_transaction( - &self, - psbt: &mut Psbt, - _sign_options: &bdk_wallet::SignOptions, - _secp: &Secp256k1, - ) -> 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::(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); -// } -// } diff --git a/crates/wallet/src/wallet/hardwaresigner.rs b/crates/wallet/src/wallet/hardwaresigner.rs deleted file mode 100644 index 3ec8d9a54..000000000 --- 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(()) - } -}