Skip to main content
The Bitcoin module decodes Partially Signed Bitcoin Transactions (PSBTs) into VisualSign payloads: what is being spent, who is being paid, and the fee.

Architecture overview

Transaction model

  • Encoding: BIP-174 PSBT version 0, supplied as base64 or hex (an optional 0x prefix is accepted). PSBT v2 (BIP-370), v2-only fields in a v0 PSBT, and trailing bytes are rejected. Encoded inputs are capped at 4 MiB; the unsigned transaction must be at most 400,000 weight units (the final signed transaction may be larger).
  • UTXO model: the PSBT carries the unsigned transaction plus per-input metadata (witness_utxo, non_witness_utxo, derivation paths, scripts).
  • Address encoding: a PSBT does not name its network. Addresses are encoded for mainnet by default; parser_cli takes --bitcoin-network (bitcoin, testnet, testnet4, signet, regtest).

Key components

The Bitcoin parser produces:
  • Address Encoding, explicitly marked transaction network unknown: the chosen encoding does not establish the transaction’s network. The enclave uses mainnet encoding; the CLI accepts the selection above.
  • One expandable Input N per input: outpoint, address, script type, amount, and where the amount came from. A witness_utxo-only amount is also marked claimed amount, unverified in the preview subtitle.
  • One expandable Output N per output: address (or the raw script for OP_RETURN and other non-address scripts), script type and amount.
  • Multisig details inside an input or output when the PSBT carries a recognized script: Multisig (threshold, script kind), Cosigner N (key and origin), and for taproot the Internal Key.
  • Fee, transaction Version, per-input Sequence (replaceability signaling and BIP-68 relative locks), and effective Lock Time when non-zero. Lock time distinguishes block heights from Unix timestamps and is marked inactive when all input sequences are final.

What the parser can and cannot vouch for

The parser holds no keys. It checks what a PSBT can prove on its own and flags the rest. Change verification (deriving a change key from an account xpub) needs wallet context the parser does not have, and belongs in the signer. The signer must enforce the PSBT sighash requests when producing signatures. The parser does not validate existing signatures or query the chain to confirm that inputs are unspent.

Using parser_cli

Test vectors

Fixtures live in src/chain_parsers/visualsign-bitcoin/tests/fixtures/. The bip174-* and bip371-* files are copied from the test vectors in BIP-174 and BIP-371; the synthetic-* files are built by the test suite from the BIP-84/BIP-86 test-vector keys.

Implementation details

The bitcoin dependency uses the C-based secp256k1-sys implementation; building this crate requires a C toolchain, including for Apple targets. Source code available at: