SFT-7352: add Blockstream crypto-account export
What changed, and why it matters
This commit adds a new feature that lets Passport hardware wallets export a Bitcoin account as a QR code formatted for Blockstream's Jade wallet. It is a straightforward feature addition with no visible security bug.
No security action required; review as normal feature code. If desired, verify that the new export format does not expose any additional key material compared to other single-sig QR exports and that the unit test coverage is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces a new wallet module (wallets/blockstream.py) that constructs a CBOR-encoded ‘crypto-account’ Uniform Resource (UR) for single-sig BIP84 P2WPKH accounts, registers it in the software wallet list, and adds a unit test that pins the exact CBOR bytes. The export uses existing SensitiveValues/stash derivation paths and returns the same key material shape as other wallet exports.
Changed components
Passport firmware wallet export subsystemports/stm32/boards/Passport/modules/wallets/blockstream.pyports/stm32/boards/Passport/modules/wallets/sw_wallets.pyports/stm32/boards/Passport/modules/tests/unit/blockstream.pyInspect captured patch +175 / −0
### ports/stm32/boards/Passport/manifest.py
@@ -340,6 +340,7 @@
('wallets/__init__.py',
'wallets/bitcoin_core.py',
'wallets/bitcoin_safe.py',
+ 'wallets/blockstream.py',
'wallets/bluewallet.py',
'wallets/btcpay.py',
'wallets/bull.py',
### ports/stm32/boards/Passport/modules/tests/test_unit.py
@@ -150,3 +150,7 @@ def test_psbt_change_validation(test):
def test_single_line_message(test):
assert test('single_line_message.py') == b'OK'
+
+
+def test_blockstream(test):
+ assert test('blockstream.py') == b'OK'
### ports/stm32/boards/Passport/modules/tests/unit/blockstream.py
@@ -0,0 +1,57 @@
+# SPDX-FileCopyrightText: © 2026 Foundation Devices, Inc. <hello@foundation.xyz>
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from ubinascii import unhexlify
+
+from data_codecs.qr_type import QRType
+from wallets.blockstream import BlockstreamWallet, create_blockstream_account_cbor
+from wallets.sw_wallets import supported_software_wallets
+
+
+public_key = unhexlify('02' + '11' * 32)
+chain_code = unhexlify('22' * 32)
+
+cbor = create_blockstream_account_cbor(public_key,
+ chain_code,
+ 0x12345678,
+ 7,
+ 0x90abcdef,
+ False)
+expected = unhexlify(
+ 'a2'
+ '011a12345678'
+ '0281d90134d90194d9012f'
+ 'a4'
+ '035821' + '02' + '11' * 32 +
+ '045820' + '22' * 32 +
+ '06d90130a3'
+ '01861854f500f507f5'
+ '021a12345678'
+ '0303'
+ '081a90abcdef')
+# This pins the tags, field order, and canonical CBOR encodings Jade accepts.
+assert cbor == expected
+
+testnet_cbor = create_blockstream_account_cbor(public_key,
+ chain_code,
+ 0x12345678,
+ 24,
+ 0x90abcdef,
+ True)
+assert testnet_cbor[0] == 0xa2
+assert b'\x05\xd9\x01\x31\xa2\x01\x00\x02\x01' in testnet_cbor
+assert b'\x01\x86\x18\x54\xf5\x01\xf5\x18\x18\xf5' in testnet_cbor
+
+assert BlockstreamWallet in supported_software_wallets
+assert BlockstreamWallet['label'] == 'Blockstream'
+assert len(BlockstreamWallet['sig_types']) == 1
+
+sig_type = BlockstreamWallet['sig_types'][0]
+assert sig_type['id'] == 'single-sig'
+
+export_modes = BlockstreamWallet['export_modes']
+assert len(export_modes) == 1
+assert export_modes[0]['id'] == 'qr'
+assert export_modes[0]['qr_type'] == QRType.UR2
+
+return_value.write(b'OK')
### ports/stm32/boards/Passport/modules/wallets/blockstream.py
@@ -0,0 +1,111 @@
+# SPDX-FileCopyrightText: © 2026 Foundation Devices, Inc. <hello@foundation.xyz>
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+import chains
+import stash
+
+from common import settings
+from data_codecs.qr_type import QRType
+from foundation import ur
+from public_constants import AF_P2WPKH
+from utils import xfp2str
+
+
+def _append_cbor_uint(result, value):
+ assert 0 <= value <= 0xffffffff
+
+ if value < 24:
+ result.append(value)
+ elif value <= 0xff:
+ result.extend(bytes([0x18, value]))
+ elif value <= 0xffff:
+ result.extend(bytes([0x19, value >> 8, value & 0xff]))
+ else:
+ result.extend(bytes([0x1a,
+ (value >> 24) & 0xff,
+ (value >> 16) & 0xff,
+ (value >> 8) & 0xff,
+ value & 0xff]))
+
+
+def create_blockstream_account_cbor(public_key,
+ chain_code,
+ master_fingerprint,
+ account_index,
+ parent_fingerprint,
+ is_testnet):
+ """Encode a BIP84 account in the crypto-account form accepted by Jade."""
+ assert len(public_key) == 33
+ assert len(chain_code) == 32
+
+ result = bytearray(b'\xa2\x01')
+ _append_cbor_uint(result, master_fingerprint)
+
+ # crypto-account outputs[0] -> crypto-output -> p2wpkh -> crypto-hdkey.
+ result.extend(b'\x02\x81\xd9\x01\x34\xd9\x01\x94\xd9\x01\x2f')
+ result.append(0xa5 if is_testnet else 0xa4)
+ result.extend(b'\x03\x58\x21')
+ result.extend(public_key)
+ result.extend(b'\x04\x58\x20')
+ 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')
+
+ 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)
+ result.append(0xf5)
+ _append_cbor_uint(result, account_index)
+ result.append(0xf5)
+ result.append(0x02)
+ _append_cbor_uint(result, master_fingerprint)
+ result.extend(b'\x03\x03\x08')
+ _append_cbor_uint(result, parent_fingerprint)
+
+ return bytes(result)
+
+
+def create_blockstream_export(sw_wallet=None,
+ addr_type=AF_P2WPKH,
+ acct_num=0,
+ multisig=False,
+ legacy=False,
+ export_mode='qr',
+ qr_type=QRType.UR2):
+ chain = chains.current_chain()
+ coin_type = chain.b44_cointype
+ account_path = "m/84'/{}'/{}'".format(coin_type, acct_num)
+ parent_path = "m/84'/{}'".format(coin_type)
+ master_fingerprint = int(xfp2str(settings.get('xfp')), 16)
+
+ with stash.SensitiveValues() as sv:
+ parent = sv.derive_path(parent_path)
+ account = sv.derive_path(account_path)
+ parent_fingerprint = int(xfp2str(parent.my_fingerprint()), 16)
+
+ cbor = create_blockstream_account_cbor(account.public_key(),
+ account.chain_code(),
+ master_fingerprint,
+ acct_num,
+ parent_fingerprint,
+ chain.ctype != 'BTC')
+
+ accts = [{'fmt': AF_P2WPKH, 'deriv': account_path, 'acct': acct_num}]
+ return (ur.new_raw('crypto-account', cbor), accts)
+
+
+BlockstreamWallet = {
+ 'label': 'Blockstream',
+ 'sig_types': [
+ {'id': 'single-sig',
+ 'label': 'Single-sig',
+ 'addr_type': AF_P2WPKH,
+ 'create_wallet': create_blockstream_export},
+ ],
+ 'export_modes': [
+ {'id': 'qr', 'label': 'QR Code', 'qr_type': QRType.UR2},
+ ],
+}
### ports/stm32/boards/Passport/modules/wallets/sw_wallets.py
@@ -6,6 +6,7 @@
from .bitcoin_core import BitcoinCoreWallet
from .bitcoin_safe import BitcoinSafeWallet
+from .blockstream import BlockstreamWallet
from .keeper import KeeperWallet
from .bluewallet import BlueWallet
from .btcpay import BtcPayWallet
@@ -34,6 +35,7 @@
EnvoyWallet,
BitcoinCoreWallet,
BitcoinSafeWallet,
+ BlockstreamWallet,
KeeperWallet,
BlueWallet,
BtcPayWallet,Why this scored 15/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.