§ 05 · Transactions · Overview
Transaction
Inputs, outputs and witnesses, byte by byte
On this page 6 sections
A transactionTransaction: A signed instruction that spends some existing outputs and creates new ones. It is how PRL moves from one owner to another. is a signed message that says: take these existing coins, and lock up new coins like this instead.
The coins it takes are its inputsInput: The part of a transaction that names an earlier output and spends it, all of it at once.. Each input points at an outputOutput: The part of a transaction that creates a new chunk of PRL: an amount in grains and a lock saying who can spend it. Pearl allows only three kinds: Taproot, P2MR and OP_RETURN. of an earlier transaction. The coins it creates are its outputs, each one an amount and a lock. Proof that the sender may unlock the inputs travels alongside in a section called the witnessWitness: The part of a transaction that carries the signatures and other unlocking data, kept apart from the part that makes the transaction ID. Every Pearl spend has one.. That’s the whole idea; the rest of this page is where each piece sits in the bytes.
Try it
Paste a raw transaction, or pick a real Pearl one, and hover any byte to see what it is.
What does a raw transaction look like?
Like this. It’s a real payment from block 130,825: one input, two outputs (2 PRL to the recipient, the rest back to the sender as change), signed with one 64-byte signature. Hover a field to name it.
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 1 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Marker marker | 1 @4 | 0x00 Segwit marker (BIP-144): says witness data follows the outputs. |
| Flag flag | 1 @5 | 0x01 Witness flag; 0x01 is the only value Pearl accepts. |
| Input count vin.length | 1 @6 | 1 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @7 | 33218153e215d1a1e80941850a696af178fc83bd6cf266be92e7ba9170553959 The transaction being spent, stored byte-reversed (internal order); shown here in normal display order. |
| Output index vin[0].vout | 4 @39 | 683 Which output of that transaction is spent (uint32 LE). |
| scriptSig length vin[0].scriptSig.length | 1 @43 | 0 Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead. |
| Sequence vin[0].sequence | 4 @44 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @48 | 2 CompactSize number of outputs. |
| Amount vout[0].value | 8 @49 | 295,646,640 grains (2.95646640 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @57 | 34 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 34 @58 | prl1p674s9jt2xs4amk6aq7ul867kcp8qwll5zsvpzzu6revewsu5z6eqv9d5z4 OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Amount vout[1].value | 8 @92 | 200,000,000 grains (2.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[1].scriptPubKey.length | 1 @100 | 34 CompactSize length of the locking script. |
| Locking script vout[1].scriptPubKey | 34 @101 | prl1pvt5a5d5z42egswfv7uscht7rv2rj3z4m8n3qp3w35592ydq88v4seuhn70 OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Witness items witness[0].length | 1 @135 | 1 Number of witness stack items for input 0. |
| Schnorr signature length witness[0][0].length | 1 @136 | 64 CompactSize length of this witness item. |
| Schnorr signature witness[0][0] | 64 @137 | 4686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba2 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime locktime | 4 @201 | 0 0: no time lock. |
205 bytes in all. Read it left to right and every field sits at a fixed spot, or right after a small length prefix that says how long the next part is.
What is the structure?
Every Pearl transaction has these fields, in this order:
| Field | Size | Type | Description |
|---|---|---|---|
| version | 4 | int32 LE | Transaction version. Pearl wallets write 1. |
| marker | 1 | 00 | Segwit marker: witness data follows. |
| flag | 1 | 01 | Segwit flag. 01 is the only value allowed. |
| input count | 1+ | CompactSize | How many inputs follow. |
| txid | 32 | hash | Input: the transaction being spent, byte-reversed. |
| vout | 4 | uint32 LE | Input: which of its outputs. |
| scriptSig length | 1+ | CompactSize | Input: always 00 except in a coinbase. |
| sequence | 4 | uint32 LE | Input: replace-by-fee signal and relative locks. Wallets write ffffffff. |
| output count | 1+ | CompactSize | How many outputs follow. |
| amount | 8 | int64 LE | Output: value in grains. |
| script length | 1+ | CompactSize | Output: length of the locking script (34 for Taproot and P2MR). |
| locking script | var | script | Output: 5120…, 5220… or 6a…. Nothing else is valid. |
| witness | var | stacks | For each input: an item count, then each item with its length. |
| locktime | 4 | uint32 LE | Earliest block height or time the transaction can be mined. Usually 0. |
Numbers are stored little-endian, smallest byte first. Counts and lengths are CompactSize numbers: one byte below 253, more only when needed.
Version
- Size
- 4 bytes
- Type
- Signed integer
- Format
- Little-endian
01000000 = 1. Oyster always writes version 1, and so does pearld’s own block template. Version 2 also appears on chain: block 130,825’s coinbase, from the Kryptex pool, uses it, as does the OP_RETURN example in this group. Consensus doesn’t check the number; relay policy accepts 1 and 2. The one thing it changes: relative locktimes only work at version 2 or above.
Marker and flag
- Size
- 1 byte each
- Type
- Constants
- Format
- 00 then 01
A 00 where the input count should be can’t be a real count (a transaction needs inputs), so it marks the segwit format, and 01 is the flag. Pearl rejects any other flag value, and rejects a flag whose witnesses are all empty. Pearl’s mempool only accepts transactions with a witness, so every normal transaction has these two bytes.
Inputs
- Size
- 41 bytes each (with an empty scriptSig)
- Type
- Outpoint ‖ scriptSig ‖ sequence
Each input names an earlier output by its transaction ID and output number, then an empty scriptSigscriptSig: An input's old-style unlocking field. In Pearl it is always empty (one 00 byte) except in the coinbase, because every spend puts its proof in the witness instead., then a sequence number. The payment above spends output 683 of transaction 33218153…553959. See inputs.
Outputs
- Size
- 43 bytes each (Taproot or P2MR)
- Type
- Amount ‖ locking script
Each output is an 8-byte amount in grains and a locking script. The payment’s outputs are 295,646,640 grains (change) and 200,000,000 grains (2 PRL to the recipient). See outputs.
Witness
- Size
- Varies
- Type
- One stack of items per input
For each input, in order: how many items, then each item’s length and bytes. A normal Taproot spend has one item, the 64-byte Schnorr signature. See witness.
Locktime
- Size
- 4 bytes
- Type
- Unsigned integer
- Format
- Little-endian
- Range
- 0 = none; below 500,000,000 = a height; from 500,000,000 = a Unix time
00000000 = no lock. Pearl wallets always write 0. See locktime and sequence.
How is a transaction identified?
By its txidTXID: A transaction's ID: the double SHA-256 hash of the transaction without its witness, shown with its bytes reversed.: SHA256d of the transaction without the marker, flag and witness, shown with its bytes reversed. For the payment above, that’s d919e02a…b384c9. Leaving the witness out means a signature can’t change the ID. The txid page does the hashing step by step.
How big is it?
| Bytes | |
|---|---|
| Total size | 205 |
| Without marker, flag and witness (base size) | 137 |
| Marker, flag and witness | 68 |
| Virtual size = 137 + ⌈68 ÷ 4⌉ | 154 vbytes |
Witness bytes count a quarter. Fees are paid per vbyteVirtual byte (vbyte): Pearl's unit of transaction size: ordinary bytes count in full and witness bytes count a quarter each. A block can hold at most 1,000,000 vbytes.: this payment paid 7,915 grains, about 51.4 grains per vbyte. The fees and vsize page has the details and the limits (a block holds 1,000,000 vbytes).
What other shapes are there?
The same format carries every kind of Pearl transaction. Each of these is real and has its own page:
- Two inputs: each input has its own outpoint and its own one-signature witness. (inputs)
- Coinbase: one input pointing at nothing, a height in the scriptSig, a witness commitment output. (coinbase)
- P2MR spend: a witness with four items: two signatures, a 71-byte script and a 1-byte control block. (P2MR)
- OP_RETURN: an output that carries 37 bytes of data and can never be spent. (OP_RETURN)
Show the two-input payment
A payment from block 130,822: two inputs, each with its own 64-byte signature in the witness.
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 1 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Marker marker | 1 @4 | 0x00 Segwit marker (BIP-144): says witness data follows the outputs. |
| Flag flag | 1 @5 | 0x01 Witness flag; 0x01 is the only value Pearl accepts. |
| Input count vin.length | 1 @6 | 2 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @7 | c50fea91a819feb5ba4a9855428ebf6438194c29394c70830321af5ac8ec7d20 The transaction being spent, stored byte-reversed (internal order); shown here in normal display order. |
| Output index vin[0].vout | 4 @39 | 0 Which output of that transaction is spent (uint32 LE). |
| scriptSig length vin[0].scriptSig.length | 1 @43 | 0 Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead. |
| Sequence vin[0].sequence | 4 @44 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Previous txid vin[1].txid | 32 @48 | f7adce4f58c72f964418112dde7f1a600968b77ff28ee17c364adbc96c31dad5 The transaction being spent, stored byte-reversed (internal order); shown here in normal display order. |
| Output index vin[1].vout | 4 @80 | 0 Which output of that transaction is spent (uint32 LE). |
| scriptSig length vin[1].scriptSig.length | 1 @84 | 0 Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead. |
| Sequence vin[1].sequence | 4 @85 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @89 | 2 CompactSize number of outputs. |
| Amount vout[0].value | 8 @90 | 125,578,616 grains (1.25578616 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @98 | 34 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 34 @99 | prl1pdupm33flla60pv3ggjnzlv5lsgha5h6wqck5jtcajxl4vump5dqq3mvacr OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Amount vout[1].value | 8 @133 | 199,000,000 grains (1.99000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[1].scriptPubKey.length | 1 @141 | 34 CompactSize length of the locking script. |
| Locking script vout[1].scriptPubKey | 34 @142 | prl1pusrlal5eu7h9j476y7c4vk6vj450e598cxcpa69hne557rk9977skn6lrw OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Witness items witness[0].length | 1 @176 | 1 Number of witness stack items for input 0. |
| Schnorr signature length witness[0][0].length | 1 @177 | 64 CompactSize length of this witness item. |
| Schnorr signature witness[0][0] | 64 @178 | bcdee9e8c70a956f0faf3f19324ff7595aa9d6d377010f12a392d5dfb8a20b05076090f11d7d6523f995c316c40b5c4c635853491a29dd5367e54e899e460638 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Witness items witness[1].length | 1 @242 | 1 Number of witness stack items for input 1. |
| Schnorr signature length witness[1][0].length | 1 @243 | 64 CompactSize length of this witness item. |
| Schnorr signature witness[1][0] | 64 @244 | 9c9a3f1689bc718d7cbf2639e1433e7bb0f01896c7f2c14a565d515c41a5b5cd0e4a748978492d8dbda559088b66ef79003d421098cc25ef4ab05b39256790b8 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime locktime | 4 @308 | 0 0: no time lock. |
In this group
- 05.01 Inputs Which coins you are spending
- 05.02 Outputs An amount and a lock
- 05.03 Witness The proofs, kept apart from the rest
- 05.04 TXID A transaction's fingerprint, and its witness twin
- 05.05 Locktime and sequence Two small fields that say "not before"
- 05.06 Fees and vsize What a transaction pays, and how its size is measured
- 05.07 UTXO Coins are outputs nobody has spent yet
- 05.08 Coinbase transaction The transaction that creates new coins
- 05.09 Sighash What exactly a signature signs