Merge pull request #682 from Foundation-Devices/codex/sft-7352-blockstream-core
What changed, and why it matters
This commit adds a new feature to the Passport hardware wallet: exporting a Bitcoin account in a format compatible with Blockstream's Jade wallet. It is a pure feature addition with no visible bug fix, defensive hardening, or security patch. There is no indication in the commit that it addresses a vulnerability.
No security action required. Review the new export format for correctness and interoperability with Blockstream Jade, and ensure the unit test remains aligned with any future Jade format changes.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge adds a new wallet module wallets/blockstream.py that constructs a CBOR-encoded crypto-account Uniform Resource (UR) for single-sig BIP84 P2WPKH accounts, matching the format accepted by Blockstream Jade. It registers the wallet in sw_wallets.py, includes it in the firmware manifest, and adds a unit test that pins the exact CBOR bytes for mainnet and testnet. The code derives the account and parent keys inside stash.SensitiveValues() and returns the UR2 QR payload plus account metadata. No security defect or remediation is present in the diff.
Changed components
ports/stm32/boards/Passport/modules/wallets/blockstream.pyports/stm32/boards/Passport/modules/wallets/sw_wallets.pyports/stm32/boards/Passport/manifest.pyports/stm32/boards/Passport/modules/tests/test_unit.pyports/stm32/boards/Passport/modules/tests/unit/blockstream.pyInspect captured patch +190 / −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
@@ -88,6 +88,10 @@ def test_ui(test):
assert test('ui.py') == b'OK'
+def test_blockstream(test):
+ assert test('blockstream.py') == b'OK'
+
+
def test_sign_psbt(test):
assert test('sign_psbt.py') == b'OK'
### ports/stm32/boards/Passport/modules/tests/unit/blockstream.py
@@ -0,0 +1,68 @@
+# 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,
+ 0)
+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,
+ 1)
+testnet_expected = unhexlify(
+ 'a2'
+ '011a12345678'
+ '0281d90134d90194d9012f'
+ 'a5'
+ '035821' + '02' + '11' * 32 +
+ '045820' + '22' * 32 +
+ '05d90131a10201'
+ '06d90130a3'
+ '01861854f501f51818f5'
+ '021a12345678'
+ '0303'
+ '081a90abcdef')
+assert testnet_cbor == testnet_expected
+
+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,115 @@
+# 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
+
+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,
+ 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
+
+ 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:
+ # 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, coin_type)
+ 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,
+ coin_type)
+
+ 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.