Skip to content

Commit 5976072

Browse files
committed
add support for BitBox02 Nova
1 parent 058a685 commit 5976072

File tree

12 files changed

+43
-16
lines changed

12 files changed

+43
-16
lines changed

CHANGELOG-npm.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## 0.10.0
44
- Add `bip85AppBip39()`
5+
- Add support for BitBox02 Nova
56

67
## 0.9.1
78
- WebHID: Automatically connect to a previoulsy connected device

CHANGELOG-rust.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.9.0
4+
- Add support for BitBox02 Nova
5+
36
## 0.8.0
47
- Add `bip85_app_bip39()`
58
- Make the `simulator` feature work with the `multithreaded` feature

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "bitbox-api"
33
authors = ["Marko Bencun <[email protected]>"]
4-
version = "0.8.0"
4+
version = "0.9.0"
55
homepage = "https://bitbox.swiss/"
66
repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/"
77
readme = "README-rust.md"
88
edition = "2021"
99
license = "Apache-2.0"
10-
description = "A library to interact with the BitBox02 hardware wallet"
10+
description = "A library to interact with BitBox hardware wallets"
1111
keywords = ["bitbox", "api", "bitcoin", "wasm"]
1212
categories = ["api-bindings", "cryptography"]
1313

sandbox/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cardano.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<R: Runtime> PairedBitBox<R> {
8989

9090
/// Does this device support Cardano functionality? Currently this means BitBox02 Multi.
9191
pub fn cardano_supported(&self) -> bool {
92-
matches!(self.product(), crate::Product::BitBox02Multi)
92+
self.is_multi_edition()
9393
}
9494

9595
/// Query the device for xpubs. The result contains one xpub per requested keypath. Each xpub is

src/communication.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ pub enum Product {
151151
Unknown,
152152
BitBox02Multi,
153153
BitBox02BtcOnly,
154+
BitBox02NovaMulti,
155+
BitBox02NovaBtcOnly,
154156
}
155157

156158
#[derive(Debug)]
@@ -187,6 +189,7 @@ async fn get_info(communication: &dyn ReadWrite) -> Result<Info, Error> {
187189

188190
let version = semver::Version::parse(version_str).or(Err(Error::Info))?;
189191
const PLATFORM_BITBOX02: u8 = 0x00;
192+
const PLATFORM_BITBOX02_NOVA: u8 = 0x02;
190193
const BITBOX02_EDITION_MULTI: u8 = 0x00;
191194
const BITBOX02_EDITION_BTCONLY: u8 = 0x01;
192195
let platform_byte = *response.first().ok_or(Error::Info)?;
@@ -198,6 +201,8 @@ async fn get_info(communication: &dyn ReadWrite) -> Result<Info, Error> {
198201
product: match (platform_byte, edition_byte) {
199202
(PLATFORM_BITBOX02, BITBOX02_EDITION_MULTI) => Product::BitBox02Multi,
200203
(PLATFORM_BITBOX02, BITBOX02_EDITION_BTCONLY) => Product::BitBox02BtcOnly,
204+
(PLATFORM_BITBOX02_NOVA, BITBOX02_EDITION_MULTI) => Product::BitBox02NovaMulti,
205+
(PLATFORM_BITBOX02_NOVA, BITBOX02_EDITION_BTCONLY) => Product::BitBox02NovaBtcOnly,
201206
_ => Product::Unknown,
202207
},
203208
unlocked: match unlocked_byte {

src/eth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<R: Runtime> PairedBitBox<R> {
3838

3939
/// Does this device support ETH functionality? Currently this means BitBox02 Multi.
4040
pub fn eth_supported(&self) -> bool {
41-
matches!(self.product(), crate::Product::BitBox02Multi)
41+
self.is_multi_edition()
4242
}
4343

4444
/// Query the device for an xpub.

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ impl<R: Runtime> PairedBitBox<R> {
346346
self.communication.info.product
347347
}
348348

349+
fn is_multi_edition(&self) -> bool {
350+
matches!(
351+
self.product(),
352+
crate::Product::BitBox02Multi | crate::Product::BitBox02NovaMulti
353+
)
354+
}
355+
349356
/// Returns the firmware version.
350357
pub fn version(&self) -> &semver::Version {
351358
&self.communication.info.version

src/usb.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ use std::sync::Mutex;
77

88
use super::communication::{Error as CommunicationError, ReadWrite};
99

10-
/// The hid product string of the multi edition firmware.
11-
const FIRMWARE_PRODUCT_STRING_MULTI: &str = "BitBox02";
12-
/// The hid product string of the btc-only edition firmware.
13-
const FIRMWARE_PRODUCT_STRING_BTCONLY: &str = "BitBox02BTC";
10+
/// The hid product string of the BitBox02 multi edition firmware.
11+
const FIRMWARE_PRODUCT_STRING_BITBOX02_MULTI: &str = "BitBox02";
12+
/// The hid product string of the BitBox02 btc-only edition firmware.
13+
const FIRMWARE_PRODUCT_STRING_BITBOX02_BTCONLY: &str = "BitBox02BTC";
14+
15+
/// The hid product string of the BitBox02 Nova multi edition firmware.
16+
const FIRMWARE_PRODUCT_STRING_BITBOX02_NOVA_MULTI: &str = "BitBox02 Nova Multi";
17+
/// The hid product string of the BitBox02 Nova btc-only edition firmware.
18+
const FIRMWARE_PRODUCT_STRING_BITBOX02_NOVA_BTCONLY: &str = "BitBox02 Nova BTC-only";
1419

1520
#[cfg(feature = "multithreaded")]
1621
pub(crate) struct HidDevice(Mutex<hidapi::HidDevice>);
@@ -75,10 +80,12 @@ pub enum UsbError {
7580
pub fn is_bitbox02(device_info: &hidapi::DeviceInfo) -> bool {
7681
(matches!(
7782
device_info.product_string(),
78-
Some(FIRMWARE_PRODUCT_STRING_MULTI)
79-
) || matches!(
80-
device_info.product_string(),
81-
Some(FIRMWARE_PRODUCT_STRING_BTCONLY)
83+
Some(
84+
FIRMWARE_PRODUCT_STRING_BITBOX02_MULTI
85+
| FIRMWARE_PRODUCT_STRING_BITBOX02_BTCONLY
86+
| FIRMWARE_PRODUCT_STRING_BITBOX02_NOVA_MULTI
87+
| FIRMWARE_PRODUCT_STRING_BITBOX02_NOVA_BTCONLY
88+
)
8289
)) && device_info.vendor_id() == VENDOR_ID
8390
&& device_info.product_id() == PRODUCT_ID
8491
&& (device_info.usage_page() == 0xffff || device_info.interface_number() == 0)

0 commit comments

Comments
 (0)