Crate hwi

source ·
Expand description

Rust wrapper for the Bitcoin Hardware Wallet Interface.

§Example - display address with path

use bitcoin::bip32::{ChildNumber, DerivationPath};
use hwi::error::Error;
use hwi::interface::HWIClient;
use hwi::types;
use std::str::FromStr;

fn main() -> Result<(), Error> {
    // Find information about devices
    let mut devices = HWIClient::enumerate()?;
    if devices.is_empty() {
        panic!("No device found!");
    }
    let device = devices.remove(0)?;
    // Create a client for a device
    let client = HWIClient::get_client(&device, true, bitcoin::Network::Testnet.into())?;
    // Display the address from path
    let derivation_path = DerivationPath::from_str("m/44'/1'/0'/0/0").unwrap();
    let hwi_address =
        client.display_address_with_path(&derivation_path, types::HWIAddressType::Tap)?;
    println!("{}", hwi_address.address.assume_checked());
    Ok(())
}

Re-exports§

Modules§