diff --git a/CHANGELOG-npm.md b/CHANGELOG-npm.md index 8424b2d..81042aa 100644 --- a/CHANGELOG-npm.md +++ b/CHANGELOG-npm.md @@ -1,5 +1,8 @@ # Changelog +## 0.11.0 +- Add `btcXpubs()` + ## 0.10.1 - package.json: use "main" instead of "module" to fix compatiblity with vitest diff --git a/CHANGELOG-rust.md b/CHANGELOG-rust.md index 5a85bfb..4988f50 100644 --- a/CHANGELOG-rust.md +++ b/CHANGELOG-rust.md @@ -1,5 +1,8 @@ # Changelog +## 0.10.0 +- Add `btc_xpubs()` + ## 0.9.0 - Add support for BitBox02 Nova diff --git a/Cargo.lock b/Cargo.lock index ad7a2d8..2fb1b52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,7 +162,7 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bitbox-api" -version = "0.9.0" +version = "0.10.0" dependencies = [ "async-trait", "base32", diff --git a/Cargo.toml b/Cargo.toml index 5efab3e..4cc44c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bitbox-api" authors = ["Marko Bencun "] -version = "0.9.0" +version = "0.10.0" homepage = "https://bitbox.swiss/" repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/" readme = "README-rust.md" diff --git a/NPM_VERSION b/NPM_VERSION index 71172b4..142464b 100644 --- a/NPM_VERSION +++ b/NPM_VERSION @@ -1 +1 @@ -0.10.1 \ No newline at end of file +0.11.0 \ No newline at end of file diff --git a/README-rust.md b/README-rust.md index 4dd62c4..fbdc025 100644 --- a/README-rust.md +++ b/README-rust.md @@ -27,7 +27,7 @@ Use `--nocapture` to also see some useful simulator output. If you want to test against a custom simulator build (e.g. when developing new firmware features), you can run: - SIMULATOR=/path/to/simulator cargo test --features=simulator,tokio + SIMULATOR=/path/to/simulator cargo test --features=simulator,tokio -- --test-threads 1 In this case, only the given simulator will be used, and the ones defined in simulators.json will be ignored. diff --git a/messages/bitbox02_system.proto b/messages/bitbox02_system.proto index a51acee..a5e8e55 100644 --- a/messages/bitbox02_system.proto +++ b/messages/bitbox02_system.proto @@ -26,6 +26,14 @@ message DeviceInfoRequest { } message DeviceInfoResponse { + message Bluetooth { + // Hash of the currently active Bluetooth firmware on the device. + bytes firmware_hash = 1; + // Firmware version, formated as an unsigned integer "1", "2", etc. + string firmware_version = 2; + // True if Bluetooth is enabled + bool enabled = 3; + } string name = 1; bool initialized = 2; string version = 3; @@ -33,6 +41,8 @@ message DeviceInfoResponse { uint32 monotonic_increments_remaining = 5; // From v9.6.0: "ATECC608A" or "ATECC608B". string securechip_model = 6; + // Only present in Bluetooth-enabled devices. + optional Bluetooth bluetooth = 7; } message InsertRemoveSDCardRequest { diff --git a/messages/bluetooth.proto b/messages/bluetooth.proto new file mode 100644 index 0000000..db98275 --- /dev/null +++ b/messages/bluetooth.proto @@ -0,0 +1,50 @@ +// Copyright 2025 Shift Crypto AG +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; +package shiftcrypto.bitbox02; + +message BluetoothToggleEnabledRequest { +} + +message BluetoothUpgradeInitRequest { + uint32 firmware_length = 1; +} + +message BluetoothChunkRequest { + bytes data = 1; +} + +message BluetoothSuccess { +} + +message BluetoothRequestChunkResponse { + uint32 offset = 1; + uint32 length = 2; +} + +message BluetoothRequest { + oneof request { + BluetoothUpgradeInitRequest upgrade_init = 1; + BluetoothChunkRequest chunk = 2; + BluetoothToggleEnabledRequest toggle_enabled = 3; + } +} + +message BluetoothResponse { + oneof response { + BluetoothSuccess success = 1; + BluetoothRequestChunkResponse request_chunk = 2; + } +} diff --git a/messages/btc.proto b/messages/btc.proto index 7a49fe4..24669ff 100644 --- a/messages/btc.proto +++ b/messages/btc.proto @@ -93,6 +93,17 @@ message BTCPubRequest { bool display = 5; } +message BTCXpubsRequest{ + enum XPubType { + UNKNOWN = 0; + XPUB = 1; + TPUB = 2; + } + BTCCoin coin = 1; + XPubType xpub_type = 2; + repeated Keypath keypaths = 3; +} + message BTCScriptConfigWithKeypath { BTCScriptConfig script_config = 2; repeated uint32 keypath = 3; @@ -281,6 +292,7 @@ message BTCRequest { BTCSignMessageRequest sign_message = 6; AntiKleptoSignatureRequest antiklepto_signature = 7; BTCPaymentRequestRequest payment_request = 8; + BTCXpubsRequest xpubs = 9; } } @@ -291,5 +303,6 @@ message BTCResponse { BTCSignNextResponse sign_next = 3; BTCSignMessageResponse sign_message = 4; AntiKleptoSignerCommitment antiklepto_signer_commitment = 5; + PubsResponse pubs = 6; } } diff --git a/messages/common.proto b/messages/common.proto index 0b80c6f..0fed08c 100644 --- a/messages/common.proto +++ b/messages/common.proto @@ -19,6 +19,10 @@ message PubResponse { string pub = 1; } +message PubsResponse { + repeated string pubs = 1; +} + message RootFingerprintRequest { } diff --git a/messages/hww.proto b/messages/hww.proto index 54c34f6..4088ae3 100644 --- a/messages/hww.proto +++ b/messages/hww.proto @@ -19,6 +19,7 @@ import "common.proto"; import "backup_commands.proto"; import "bitbox02_system.proto"; +import "bluetooth.proto"; import "btc.proto"; import "cardano.proto"; import "eth.proto"; @@ -67,6 +68,7 @@ message Request { ElectrumEncryptionKeyRequest electrum_encryption_key = 26; CardanoRequest cardano = 27; BIP85Request bip85 = 28; + BluetoothRequest bluetooth = 29; } } @@ -89,5 +91,6 @@ message Response { ElectrumEncryptionKeyResponse electrum_encryption_key = 14; CardanoResponse cardano = 15; BIP85Response bip85 = 16; + BluetoothResponse bluetooth = 17; } } diff --git a/sandbox/src/Bitcoin.tsx b/sandbox/src/Bitcoin.tsx index e6c8636..9438448 100644 --- a/sandbox/src/Bitcoin.tsx +++ b/sandbox/src/Bitcoin.tsx @@ -76,6 +76,73 @@ function BtcXPub({ bb02 } : Props) { ); } + +function BtcXPubs({ bb02 } : Props) { + const [coin, setCoin] = useState('btc'); + const [keypaths, setKeypaths] = useState(`["m/49'/0'/0'", "m/84'/0'/0'", "m/86'/0'/0'"]`); + const [xpubType, setXpubType] = useState('xpub'); + const [result, setResult] = useState(); + const [running, setRunning] = useState(false); + const [err, setErr] = useState(); + + const btcXPubsTypeOptions = ['tpub', 'xpub']; + + const submitForm = async (e: FormEvent) => { + e.preventDefault(); + setRunning(true); + setResult(undefined); + setErr(undefined); + try { + setResult(await bb02.btcXpubs(coin, JSON.parse(keypaths), xpubType)); + } catch (err) { + throw err; + setErr(bitbox.ensureError(err)); + } finally { + setRunning(false); + } + } + + + return ( +
+

Multiple XPubs

+
+ + +