pub struct HWIClient { /* private fields */ }
Implementations
sourceimpl HWIClient
impl HWIClient
sourcepub fn enumerate() -> Result<Vec<HWIDevice>, Error>
pub fn enumerate() -> Result<Vec<HWIDevice>, Error>
Lists all HW devices currently connected.
let devices = HWIClient::enumerate()?;
for device in devices {
println!("I can see a {} here 😄", device.model);
}
sourcepub fn get_client(
device: &HWIDevice,
expert: bool,
chain: HWIChain
) -> Result<HWIClient, Error>
pub fn get_client(
device: &HWIDevice,
expert: bool,
chain: HWIChain
) -> Result<HWIClient, Error>
Returns the HWIClient for a certain device. You can list all the available devices using
enumerate
.
Setting expert
to true
will enable additional output for some commands.
let devices = HWIClient::enumerate()?;
for device in devices {
let client = HWIClient::get_client(&device, false, HWIChain::Test)?;
let xpub = client.get_master_xpub(HWIAddressType::Tap, 0)?;
println!(
"I can see a {} here, and its xpub is {}",
device.model,
xpub.to_string()
);
}
sourcepub fn get_master_xpub(
&self,
addrtype: HWIAddressType,
account: u32
) -> Result<HWIExtendedPubKey, Error>
pub fn get_master_xpub(
&self,
addrtype: HWIAddressType,
account: u32
) -> Result<HWIExtendedPubKey, Error>
Returns the master xpub of a device, given the address type and the account number.
sourcepub fn sign_tx(
&self,
psbt: &PartiallySignedTransaction
) -> Result<HWIPartiallySignedTransaction, Error>
pub fn sign_tx(
&self,
psbt: &PartiallySignedTransaction
) -> Result<HWIPartiallySignedTransaction, Error>
Signs a PSBT.
sourcepub fn get_xpub(
&self,
path: &DerivationPath,
expert: bool
) -> Result<HWIExtendedPubKey, Error>
pub fn get_xpub(
&self,
path: &DerivationPath,
expert: bool
) -> Result<HWIExtendedPubKey, Error>
Returns the xpub of a device. If expert
is set, additional output is returned.
sourcepub fn sign_message(
&self,
message: &str,
path: &DerivationPath
) -> Result<HWISignature, Error>
pub fn sign_message(
&self,
message: &str,
path: &DerivationPath
) -> Result<HWISignature, Error>
Signs a message.
sourcepub fn get_keypool(
&self,
keypool: bool,
internal: bool,
addr_type: HWIAddressType,
addr_all: bool,
account: Option<u32>,
path: Option<&DerivationPath>,
start: u32,
end: u32
) -> Result<Vec<HWIKeyPoolElement>, Error>
pub fn get_keypool(
&self,
keypool: bool,
internal: bool,
addr_type: HWIAddressType,
addr_all: bool,
account: Option<u32>,
path: Option<&DerivationPath>,
start: u32,
end: u32
) -> Result<Vec<HWIKeyPoolElement>, Error>
Returns an array of keys that can be imported in Bitcoin core using importmulti
keypool
-keypool
value in result. Check bitcoin core importmulti documentation for further informationinternal
- Whether to use internal (change) or external keysaddr_type
- Address type to useaddr_all
- Whether to return a multiple descriptors for every address typeaccount
- Optional BIP43 account to usepath
- The derivation path to derive the keys.start
- Keypool startend
- Keypool end
sourcepub fn get_descriptors(
&self,
account: Option<u32>
) -> Result<HWIDescriptor, Error>
pub fn get_descriptors(
&self,
account: Option<u32>
) -> Result<HWIDescriptor, Error>
Returns device descriptors. You can optionally specify a BIP43 account to use.
sourcepub fn display_address_with_desc(
&self,
descriptor: &str
) -> Result<HWIAddress, Error>
pub fn display_address_with_desc(
&self,
descriptor: &str
) -> Result<HWIAddress, Error>
Returns an address given a descriptor. Note that HWI doesn’t support descriptors checksums.
sourcepub fn display_address_with_path(
&self,
path: &DerivationPath,
address_type: HWIAddressType
) -> Result<HWIAddress, Error>
pub fn display_address_with_path(
&self,
path: &DerivationPath,
address_type: HWIAddressType
) -> Result<HWIAddress, Error>
Returns an address given path and address type.
sourcepub fn install_udev_rules(
source: Option<&str>,
location: Option<&str>
) -> Result<(), Error>
pub fn install_udev_rules(
source: Option<&str>,
location: Option<&str>
) -> Result<(), Error>
Install the udev rules to the local machine.
The rules will be copied from the source to the location; the default source location is
./udev
, the default destination location is /lib/udev/rules.d
sourcepub fn toggle_passphrase(&self) -> Result<(), Error>
pub fn toggle_passphrase(&self) -> Result<(), Error>
Toggle whether the device is using a BIP 39 passphrase.
sourcepub fn wipe_device(&self) -> Result<(), Error>
pub fn wipe_device(&self) -> Result<(), Error>
Wipe a device
sourcepub fn get_version() -> Option<String>
pub fn get_version() -> Option<String>
Get the installed version of hwilib. Returns None if hwi is not installed.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for HWIClient
impl Send for HWIClient
impl Sync for HWIClient
impl Unpin for HWIClient
impl UnwindSafe for HWIClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more