Architecture overview
Transaction model
- Encoding: BIP-174 PSBT version 0, supplied as base64 or hex (an optional
0xprefix 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_clitakes--bitcoin-network(bitcoin,testnet,testnet4,signet,regtest).
Key components
The Bitcoin parser produces:Address Encoding, explicitly markedtransaction 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 Nper input: outpoint, address, script type, amount, and where the amount came from. Awitness_utxo-only amount is also markedclaimed amount, unverifiedin the preview subtitle. - One expandable
Output Nper output: address (or the raw script forOP_RETURNand 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 theInternal Key. Fee, transactionVersion, per-inputSequence(replaceability signaling and BIP-68 relative locks), and effectiveLock Timewhen 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 insrc/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
Thebitcoin dependency uses the C-based secp256k1-sys implementation; building this crate requires a C toolchain, including for Apple targets.
Source code available at: