Struct PairedBitBox

Source
pub struct PairedBitBox<R: Runtime> { /* private fields */ }
Expand description

Paired BitBox. This is where you can invoke most API functions like getting xpubs, displaying receive addresses, etc.

Implementations§

Source§

impl<R: Runtime> PairedBitBox<R>

Source

pub async fn btc_xpub( &self, coin: BtcCoin, keypath: &Keypath, xpub_type: XPubType, display: bool, ) -> Result<String, Error>

Retrieves an xpub. For non-standard keypaths, a warning is displayed on the BitBox even if display is false.

Source

pub async fn btc_address( &self, coin: BtcCoin, keypath: &Keypath, script_config: &BtcScriptConfig, display: bool, ) -> Result<String, Error>

Retrieves a Bitcoin address at the provided keypath.

For the simple script configs (single-sig), the keypath must follow the BIP44/BIP49/BIP84/BIP86 conventions.

Source

pub async fn btc_sign( &self, coin: BtcCoin, transaction: &Transaction, format_unit: FormatUnit, ) -> Result<Vec<Vec<u8>>, Error>

Sign a Bitcoin transaction. Returns one 64 byte signature (compact serlization of the R and S values) per input.

Source

pub async fn btc_sign_psbt( &self, coin: BtcCoin, psbt: &mut Psbt, force_script_config: Option<BtcScriptConfigWithKeypath>, format_unit: FormatUnit, ) -> Result<(), Error>

Sign a PSBT.

If force_script_config is None, we attempt to infer the involved script configs. For the simple script config (single sig), we infer the script config from the involved redeem scripts and provided derviation paths.

Multisig and policy configs are currently not inferred and must be provided using force_script_config.

Source

pub async fn btc_sign_message( &self, coin: BtcCoin, script_config: BtcScriptConfigWithKeypath, msg: &[u8], ) -> Result<SignMessageSignature, Error>

Sign a message.

Source

pub async fn btc_is_script_config_registered( &self, coin: BtcCoin, script_config: &BtcScriptConfig, keypath_account: Option<&Keypath>, ) -> Result<bool, Error>

Before a multisig or policy script config can be used to display receive addresses or sign transactions, it must be registered on the device. This function checks if the script config was already registered.

keypath_account must be set if the script config is multisig, and can be None if it is a policy.

Source

pub async fn btc_register_script_config( &self, coin: BtcCoin, script_config: &BtcScriptConfig, keypath_account: Option<&Keypath>, xpub_type: XPubType, name: Option<&str>, ) -> Result<(), Error>

Before a multisig or policy script config can be used to display receive addresses or sign transcations, it must be registered on the device.

If no name is provided, the user will be asked to enter it on the device instead. If provided, it must be non-empty, smaller or equal to 30 chars, consist only of printable ASCII characters, and contain no whitespace other than spaces.

keypath_account must be set if the script config is multisig, and can be None if it is a policy.

Source§

impl<R: Runtime> PairedBitBox<R>

Source

pub fn cardano_supported(&self) -> bool

Does this device support Cardano functionality? Currently this means BitBox02 Multi.

Source

pub async fn cardano_xpubs( &self, keypaths: &[Keypath], ) -> Result<Vec<Vec<u8>>, Error>

Query the device for xpubs. The result contains one xpub per requested keypath. Each xpub is 64 bytes: 32 byte chain code + 32 byte pubkey.

Source

pub async fn cardano_address( &self, network: CardanoNetwork, script_config: &CardanoScriptConfig, display: bool, ) -> Result<String, Error>

Query the device for a Cardano address.

Source

pub async fn cardano_sign_transaction( &self, transaction: CardanoSignTransactionRequest, ) -> Result<CardanoSignTransactionResponse, Error>

Sign a Cardano transaction.

Source§

impl<R: Runtime> PairedBitBox<R>

Source

pub fn eth_supported(&self) -> bool

Does this device support ETH functionality? Currently this means BitBox02 Multi.

Source

pub async fn eth_xpub(&self, keypath: &Keypath) -> Result<String, Error>

Query the device for an xpub.

Source

pub async fn eth_address( &self, chain_id: u64, keypath: &Keypath, display: bool, ) -> Result<String, Error>

Query the device for an Ethereum address.

Source§

impl<R: Runtime> PairedBitBox<R>

Source

pub async fn eth_sign_transaction( &self, chain_id: u64, keypath: &Keypath, tx: &Transaction, address_case: Option<EthAddressCase>, ) -> Result<[u8; 65], Error>

Signs an Ethereum transaction. It returns a 65 byte signature (R, S, and 1 byte recID). The tx param can be constructed manually or parsed from a raw transaction using raw_tx_slice.try_into() (rlp feature required).

Source

pub async fn eth_sign_1559_transaction( &self, keypath: &Keypath, tx: &EIP1559Transaction, address_case: Option<EthAddressCase>, ) -> Result<[u8; 65], Error>

Signs an Ethereum type 2 transaction according to EIP 1559. It returns a 65 byte signature (R, S, and 1 byte recID). The tx param can be constructed manually or parsed from a raw transaction using raw_tx_slice.try_into() (rlp feature required).

Source

pub async fn eth_sign_message( &self, chain_id: u64, keypath: &Keypath, msg: &[u8], ) -> Result<[u8; 65], Error>

Signs an Ethereum message. The provided msg will be prefixed with “\x19Ethereum message\n” + len(msg) in the hardware, e.g. “\x19Ethereum\n5hello” (yes, the len prefix is the ascii representation with no fixed size or delimiter). It returns a 65 byte signature (R, S, and 1 byte recID). 27 is added to the recID to denote an uncompressed pubkey.

Source

pub async fn eth_sign_typed_message( &self, chain_id: u64, keypath: &Keypath, json_msg: &str, ) -> Result<[u8; 65], Error>

Signs an Ethereum EIP-712 typed message. It returns a 65 byte signature (R, S, and 1 byte recID). 27 is added to the recID to denote an uncompressed pubkey.

Source§

impl<R: Runtime> PairedBitBox<R>

Source

pub async fn device_info(&self) -> Result<DeviceInfoResponse, Error>

Source

pub fn product(&self) -> Product

Returns which product we are connected to.

Source

pub fn version(&self) -> &Version

Returns the firmware version.

Source

pub async fn root_fingerprint(&self) -> Result<String, Error>

Returns the hex-encoded 4-byte root fingerprint.

Source

pub async fn show_mnemonic(&self) -> Result<(), Error>

Show recovery words on the Bitbox.

Source

pub async fn restore_from_mnemonic(&self) -> Result<(), Error>

Restore from recovery words on the Bitbox.

Source

pub async fn bip85_app_bip39(&self) -> Result<(), Error>

Invokes the BIP85-BIP39 workflow on the device, letting the user select the number of words (12, 28, 24) and an index and display a derived BIP-39 mnemonic.

Auto Trait Implementations§

§

impl<R> !Freeze for PairedBitBox<R>

§

impl<R> !RefUnwindSafe for PairedBitBox<R>

§

impl<R> !Send for PairedBitBox<R>

§

impl<R> !Sync for PairedBitBox<R>

§

impl<R> Unpin for PairedBitBox<R>
where R: Unpin,

§

impl<R> !UnwindSafe for PairedBitBox<R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.