What is a raw Bitcoin transaction?
A raw Bitcoin transaction is the hex serialization of version, inputs (previous txid and output index, scriptSig, sequence), outputs (value in satoshis and scriptPubKey), optional SegWit witness data and locktime. The txid is the double SHA-256 of the serialization without witness data, and a PSBT (BIP-174) wraps an unsigned transaction with the metadata signers need.
Reading the result
- Inputs list the previous outpoint (txid:index), the spend type and the derived address. The sequence shows whether RBF is signalled.
- Outputs list value, script type and address. OP_RETURN outputs show their payload as text when it is printable, otherwise as hex.
- Locktime is interpreted as a block height below 500,000,000 and as a Unix timestamp above it.
- Signed / unsigned is judged by whether every input carries a scriptSig or witness.
Output script types
| Type | scriptPubKey pattern | Address | Spend data |
|---|---|---|---|
| P2PKH | OP_DUP OP_HASH160 <20 bytes> OP_EQUALVERIFY OP_CHECKSIG | 1… | scriptSig: signature + public key |
| P2SH | OP_HASH160 <20 bytes> OP_EQUAL | 3… | scriptSig ends with the redeem script |
| P2WPKH | OP_0 <20 bytes> | bc1q… (42 chars) | witness: signature, public key |
| P2WSH | OP_0 <32 bytes> | bc1q… (62 chars) | witness ends with the witness script |
| P2TR | OP_1 <32 bytes> | bc1p… | witness: 64-byte signature (key path) |
| OP_RETURN | OP_RETURN <data> | none, unspendable | n/a |
Worked example: weight and vsize
A transaction with one P2WPKH input and two P2WPKH outputs has 113 bytes of non-witness data (version, input, two outputs, locktime) and about 110 bytes of witness data (marker, flag, a 72-byte signature and a 33-byte public key). Weight = 113 × 4 + 110 = 562 weight units, so vsize = ⌈562 ÷ 4⌉ = 141 vbytes. At 10 sat/vB the fee is 1,410 sats. The same payment from a legacy P2PKH input is roughly 226 bytes, all counted at full weight, for 226 vbytes.
Where the raw hex comes from
Bitcoin Core: getrawtransaction <txid> or createrawtransaction. Electrum and Sparrow: export transaction as hex. Explorers: mempool.space and blockstream.info expose /api/tx/<txid>/hex. Hardware wallets show the PSBT they are asked to sign.
Validate an address on its own with the Bitcoin address validator, or inspect bech32 strings with the bech32 decoder.