Crates.io | hwi |
lib.rs | hwi |
version | 0.10.0 |
source | src |
created_at | 2020-03-14 16:45:08.73109 |
updated_at | 2024-09-13 17:50:28.567544 |
description | Rust wrapper for the Bitcoin Core Hardware Wallet Interface. |
homepage | |
repository | https://github.com/bitcoindevkit/rust-hwi |
max_upload_size | |
id | 218608 |
size | 63,513 |
Rust wrapper for the Bitcoin Hardware Wallet Interface library.
This library internally uses PyO3 to call HWI's functions. It is not a re-implementation of HWI in native Rust.
The MSRV for this project is 1.63.0
.
Python 3 is required. The libraries and udev rules for each device must also be installed. Some libraries will need to be installed
For Ubuntu/Debian:
sudo apt install libusb-1.0-0-dev libudev-dev python3-dev
For Centos:
sudo yum -y install python3-devel libusbx-devel systemd-devel
For macOS:
brew install libusb
git clone https://github.com/bitcoindevkit/rust-hwi.git && cd rust-hwi
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
use bitcoin::Network;
use bitcoin::bip32::DerivationPath;
use hwi::error::Error;
use hwi::HWIClient;
use std::str::FromStr;
fn main() -> Result<(), Error> {
let mut devices = HWIClient::enumerate()?;
if devices.is_empty() {
panic!("No devices found!");
}
let first_device = devices.remove(0)?;
let client = HWIClient::get_client(&first_device, true, Network::Bitcoin.into())?;
let derivation_path = DerivationPath::from_str("m/44'/1'/0'/0/0").unwrap();
let s = client.sign_message("I love BDK wallet", &derivation_path)?;
println!("{:?}", s.signature);
Ok(())
}
To run the tests, you need to have a hardware wallet plugged in. If you don't have a HW for testing, you can try:
Don't use a device with funds for testing!
Either use a testing device with no funds, or use a simulator.
You can run the tests with cargo test
.