SFT-7352: align Blockstream account export metadata
What changed, and why it matters
This commit tweaks how the Passport hardware wallet exports a Bitcoin account to the Blockstream Jade wallet format. It changes the way the 'testnet/mainnet' coin type is encoded in the exported data so it matches what Jade's own software produces. There is no obvious security vulnerability here; it is a compatibility/alignment fix that could prevent the receiving wallet from misinterpreting the account type.
Treat as a routine compatibility fix. Reviewers should verify that the new CBOR encoding is accepted by current Jade/Blockstream wallet software and that mainnet exports remain unchanged. No security patch or incident response is indicated.
Security signals we found
CBOR metadata encoding change for wallet export compatibility
Testnet/mainnet indicator changed from boolean to explicit coin_type integer
Removal of default Bitcoin type field in crypto-coin-info CBOR map
No input validation changes beyond asserting coin_type in (0, 1)
No cryptographic operations, key handling, or memory safety changes
Evidence from the diff
The patch refactors create_blockstream_account_cbor() to take a numeric coin_type (0 for mainnet, 1 for testnet) instead of a boolean is_testnet. For testnet exports, the CBOR-encoded crypto-coin-info map is changed from a two-key map {type: 0, network: 1} to a single-key map {network: 1}, omitting the default Bitcoin coin type. The caller now passes chain.ctype-derived coin_type rather than a boolean. Unit test expectations are updated accordingly. This aligns Passport’s output with the ‘native registry encoder’ used by Casa/Jade.
Changed components
ports/stm32/boards/Passport/modules/wallets/blockstream.pyports/stm32/boards/Passport/modules/tests/unit/blockstream.pyInspect captured patch +12 / −8
### ports/stm32/boards/Passport/modules/tests/unit/blockstream.py
@@ -16,7 +16,7 @@
0x12345678,
7,
0x90abcdef,
- False)
+ 0)
expected = unhexlify(
'a2'
'011a12345678'
@@ -37,15 +37,15 @@
0x12345678,
24,
0x90abcdef,
- True)
+ 1)
testnet_expected = unhexlify(
'a2'
'011a12345678'
'0281d90134d90194d9012f'
'a5'
'035821' + '02' + '11' * 32 +
'045820' + '22' * 32 +
- '05d90131a201000201'
+ '05d90131a10201'
'06d90130a3'
'01861854f501f51818f5'
'021a12345678'
### ports/stm32/boards/Passport/modules/wallets/blockstream.py
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: © 2026 Foundation Devices, Inc. <hello@foundation.xyz>
# SPDX-License-Identifier: GPL-3.0-or-later
+"""Export one BIP84 key; the native crypto-account encoder requires two Casa keys."""
+
import chains
import stash
@@ -33,8 +35,10 @@ def create_blockstream_account_cbor(public_key,
master_fingerprint,
account_index,
parent_fingerprint,
- is_testnet):
+ coin_type):
"""Encode a BIP84 account in the crypto-account form accepted by Jade."""
+ assert coin_type in (0, 1)
+ is_testnet = coin_type == 1
assert len(public_key) == 33
assert len(chain_code) == 32
@@ -50,13 +54,13 @@ def create_blockstream_account_cbor(public_key,
result.extend(chain_code)
if is_testnet:
- # crypto-coin-info: Bitcoin (type 0), testnet (network 1).
- result.extend(b'\x05\xd9\x01\x31\xa2\x01\x00\x02\x01')
+ # Omit the default Bitcoin type, matching the native registry encoder.
+ result.extend(b'\x05\xd9\x01\x31\xa1\x02\x01')
result.extend(b'\x06\xd9\x01\x30\xa3\x01\x86')
_append_cbor_uint(result, 84)
result.append(0xf5)
- _append_cbor_uint(result, 1 if is_testnet else 0)
+ _append_cbor_uint(result, coin_type)
result.append(0xf5)
_append_cbor_uint(result, account_index)
result.append(0xf5)
@@ -91,7 +95,7 @@ def create_blockstream_export(sw_wallet=None,
master_fingerprint,
acct_num,
parent_fingerprint,
- chain.ctype != 'BTC')
+ coin_type)
accts = [{'fmt': AF_P2WPKH, 'deriv': account_path, 'acct': acct_num}]
return (ur.new_raw('crypto-account', cbor), accts)Why this scored 22/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.