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>
impl<R: Runtime> PairedBitBox<R>
Sourcepub async fn btc_xpub(
&self,
coin: BtcCoin,
keypath: &Keypath,
xpub_type: XPubType,
display: bool,
) -> Result<String, Error>
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.
Sourcepub async fn btc_address(
&self,
coin: BtcCoin,
keypath: &Keypath,
script_config: &BtcScriptConfig,
display: bool,
) -> Result<String, Error>
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.
Sourcepub async fn btc_sign(
&self,
coin: BtcCoin,
transaction: &Transaction,
format_unit: FormatUnit,
) -> Result<Vec<Vec<u8>>, Error>
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.
Sourcepub async fn btc_sign_psbt(
&self,
coin: BtcCoin,
psbt: &mut Psbt,
force_script_config: Option<BtcScriptConfigWithKeypath>,
format_unit: FormatUnit,
) -> Result<(), Error>
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
.
Sourcepub async fn btc_sign_message(
&self,
coin: BtcCoin,
script_config: BtcScriptConfigWithKeypath,
msg: &[u8],
) -> Result<SignMessageSignature, Error>
pub async fn btc_sign_message( &self, coin: BtcCoin, script_config: BtcScriptConfigWithKeypath, msg: &[u8], ) -> Result<SignMessageSignature, Error>
Sign a message.
Sourcepub async fn btc_is_script_config_registered(
&self,
coin: BtcCoin,
script_config: &BtcScriptConfig,
keypath_account: Option<&Keypath>,
) -> Result<bool, Error>
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.
Sourcepub async fn btc_register_script_config(
&self,
coin: BtcCoin,
script_config: &BtcScriptConfig,
keypath_account: Option<&Keypath>,
xpub_type: XPubType,
name: Option<&str>,
) -> Result<(), Error>
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>
impl<R: Runtime> PairedBitBox<R>
Sourcepub fn cardano_supported(&self) -> bool
pub fn cardano_supported(&self) -> bool
Does this device support Cardano functionality? Currently this means BitBox02 Multi.
Sourcepub async fn cardano_xpubs(
&self,
keypaths: &[Keypath],
) -> Result<Vec<Vec<u8>>, Error>
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.
Sourcepub async fn cardano_address(
&self,
network: CardanoNetwork,
script_config: &CardanoScriptConfig,
display: bool,
) -> Result<String, Error>
pub async fn cardano_address( &self, network: CardanoNetwork, script_config: &CardanoScriptConfig, display: bool, ) -> Result<String, Error>
Query the device for a Cardano address.
Sourcepub async fn cardano_sign_transaction(
&self,
transaction: CardanoSignTransactionRequest,
) -> Result<CardanoSignTransactionResponse, Error>
pub async fn cardano_sign_transaction( &self, transaction: CardanoSignTransactionRequest, ) -> Result<CardanoSignTransactionResponse, Error>
Sign a Cardano transaction.
Source§impl<R: Runtime> PairedBitBox<R>
impl<R: Runtime> PairedBitBox<R>
Source§impl<R: Runtime> PairedBitBox<R>
impl<R: Runtime> PairedBitBox<R>
Sourcepub async fn eth_sign_transaction(
&self,
chain_id: u64,
keypath: &Keypath,
tx: &Transaction,
address_case: Option<EthAddressCase>,
) -> Result<[u8; 65], Error>
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).
Sourcepub async fn eth_sign_1559_transaction(
&self,
keypath: &Keypath,
tx: &EIP1559Transaction,
address_case: Option<EthAddressCase>,
) -> Result<[u8; 65], Error>
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).
Sourcepub async fn eth_sign_message(
&self,
chain_id: u64,
keypath: &Keypath,
msg: &[u8],
) -> Result<[u8; 65], Error>
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§impl<R: Runtime> PairedBitBox<R>
impl<R: Runtime> PairedBitBox<R>
pub async fn device_info(&self) -> Result<DeviceInfoResponse, Error>
Sourcepub async fn root_fingerprint(&self) -> Result<String, Error>
pub async fn root_fingerprint(&self) -> Result<String, Error>
Returns the hex-encoded 4-byte root fingerprint.
Sourcepub async fn show_mnemonic(&self) -> Result<(), Error>
pub async fn show_mnemonic(&self) -> Result<(), Error>
Show recovery words on the Bitbox.
Sourcepub async fn restore_from_mnemonic(&self) -> Result<(), Error>
pub async fn restore_from_mnemonic(&self) -> Result<(), Error>
Restore from recovery words on the Bitbox.
Sourcepub async fn bip85_app_bip39(&self) -> Result<(), Error>
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.