Merge bitcoindevkit/bdk#825: Bump hwi to 0.4.0
4cad18bbcaa8199b82c10291aa38941f06823568 Bump hwi to 0.4.0 (Daniela Brozzoni) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ### Changelog notice - Bump hwi to 0.4.0 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: notmandatory: ACK 4cad18bbcaa8199b82c10291aa38941f06823568 Tree-SHA512: 6c73c091da743734ed87e4792f3c2a838ac7aa252388309ad46e017cc7e9b338bfdb7ed70925c8041a7d22a4d12e2a984e902619b1b7735c645e6c1b6855aeb3
This commit is contained in:
commit
5a483472c1
@ -31,7 +31,7 @@ async-trait = { version = "0.1", optional = true }
|
||||
rocksdb = { version = "0.14", default-features = false, features = ["snappy"], optional = true }
|
||||
cc = { version = ">=1.0.64", optional = true }
|
||||
socks = { version = "0.3", optional = true }
|
||||
hwi = { version = "0.3.0", optional = true }
|
||||
hwi = { version = "0.4.0", optional = true, features = [ "use-miniscript"] }
|
||||
|
||||
bip39 = { version = "1.0.1", optional = true }
|
||||
bitcoinconsensus = { version = "0.19.0-3", optional = true }
|
||||
|
@ -2,6 +2,7 @@ use bdk::bitcoin::{Address, Network};
|
||||
use bdk::blockchain::{Blockchain, ElectrumBlockchain};
|
||||
use bdk::database::MemoryDatabase;
|
||||
use bdk::hwi::{types::HWIChain, HWIClient};
|
||||
use bdk::miniscript::{Descriptor, DescriptorPublicKey};
|
||||
use bdk::signer::SignerOrdering;
|
||||
use bdk::wallet::{hardwaresigner::HWISigner, AddressIndex};
|
||||
use bdk::{FeeRate, KeychainKind, SignOptions, SyncOptions, Wallet};
|
||||
@ -23,26 +24,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("Hold tight, I'm connecting to your hardware wallet...");
|
||||
|
||||
// Listing all the available hardware wallet devices...
|
||||
let devices = HWIClient::enumerate()?;
|
||||
let first_device = devices
|
||||
.first()
|
||||
.expect("No devices found. Either plug in a hardware wallet, or start a simulator.");
|
||||
let mut devices = HWIClient::enumerate()?;
|
||||
if devices.is_empty() {
|
||||
panic!("No devices found. Either plug in a hardware wallet, or start a simulator.");
|
||||
}
|
||||
let first_device = devices.remove(0)?;
|
||||
// ...and creating a client out of the first one
|
||||
let client = HWIClient::get_client(first_device, true, HWIChain::Test)?;
|
||||
let client = HWIClient::get_client(&first_device, true, HWIChain::Test)?;
|
||||
println!("Look what I found, a {}!", first_device.model);
|
||||
|
||||
// Getting the HW's public descriptors
|
||||
let descriptors = client.get_descriptors(None)?;
|
||||
let descriptors = client.get_descriptors::<Descriptor<DescriptorPublicKey>>(None)?;
|
||||
println!(
|
||||
"The hardware wallet's descriptor is: {}",
|
||||
descriptors.receive[0]
|
||||
);
|
||||
|
||||
// Creating a custom signer from the device
|
||||
let custom_signer = HWISigner::from_device(first_device, HWIChain::Test)?;
|
||||
let custom_signer = HWISigner::from_device(&first_device, HWIChain::Test)?;
|
||||
let mut wallet = Wallet::new(
|
||||
&descriptors.receive[0],
|
||||
Some(&descriptors.internal[0]),
|
||||
descriptors.receive[0].clone(),
|
||||
Some(descriptors.internal[0].clone()),
|
||||
Network::Testnet,
|
||||
MemoryDatabase::default(),
|
||||
)?;
|
||||
|
@ -24,9 +24,12 @@
|
||||
//! # use std::sync::Arc;
|
||||
//! #
|
||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
//! 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 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, HWIChain::Test)?;
|
||||
//!
|
||||
//! # let mut wallet = Wallet::new(
|
||||
//! # "",
|
||||
|
@ -5546,11 +5546,14 @@ pub(crate) mod test {
|
||||
use hwi::types::HWIChain;
|
||||
use hwi::HWIClient;
|
||||
|
||||
let devices = HWIClient::enumerate().unwrap();
|
||||
let device = devices.first().expect("No devices found");
|
||||
let client = HWIClient::get_client(device, true, HWIChain::Regtest).unwrap();
|
||||
let descriptors = client.get_descriptors(None).unwrap();
|
||||
let custom_signer = HWISigner::from_device(device, HWIChain::Regtest).unwrap();
|
||||
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, HWIChain::Regtest).unwrap();
|
||||
let descriptors = client.get_descriptors::<String>(None).unwrap();
|
||||
let custom_signer = HWISigner::from_device(&device, HWIChain::Regtest).unwrap();
|
||||
|
||||
let (mut wallet, _, _) = get_funded_wallet(&descriptors.internal[0]);
|
||||
wallet.add_signer(
|
||||
|
Loading…
x
Reference in New Issue
Block a user