§ 05

§ 05 · Transactions · Overview

Transaction

Inputs, outputs and witnesses, byte by byte

A transaction is a signed message that says: take these existing coins, and lock up new coins like this instead.

The coins it takes are its inputs. Each input points at an output 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 witness. 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.

Transaction decoder

Paste raw hex: every byte colored and explained

A typical payment: 1 input, 2 outputs (block 130,825) 205 bytes
010000000001015939557091bae792be66f26cbd83fc78f16a690a854109e8a1d115e253812133ab02000000ffffffff02b0359f1100000000225120d7ab02c96a342bdddb5d07b9f3ebd6c04e077ff41418110b9a1e5997439416b200c2eb0b0000000022512062e9da3682aab288392cf7218bafc36287288abb3ce200c5d1a50aa234073b2b01404686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba200000000
Hover or focus the bytes, or a row below, to name each field
All 19 fields
FieldBytesValue
Versionversion4@01int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.
Markermarker1@40x00Segwit marker (BIP-144): says witness data follows the outputs.
Flagflag1@50x01Witness flag; 0x01 is the only value Pearl accepts.
Input countvin.length1@61CompactSize number of inputs.
Previous txidvin[0].txid32@733218153e215d1a1e80941850a696af178fc83bd6cf266be92e7ba9170553959The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.
Output indexvin[0].vout4@39683Which output of that transaction is spent (uint32 LE).
scriptSig lengthvin[0].scriptSig.length1@430Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.
Sequencevin[0].sequence4@440xffffffffFinal (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this.
Output countvout.length1@482CompactSize number of outputs.
Amountvout[0].value8@49295,646,640 grains (2.95646640 PRL)int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script lengthvout[0].scriptPubKey.length1@5734CompactSize length of the locking script.
Locking scriptvout[0].scriptPubKey34@58prl1p674s9jt2xs4amk6aq7ul867kcp8qwll5zsvpzzu6revewsu5z6eqv9d5z4OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output.
Amountvout[1].value8@92200,000,000 grains (2.00000000 PRL)int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script lengthvout[1].scriptPubKey.length1@10034CompactSize length of the locking script.
Locking scriptvout[1].scriptPubKey34@101prl1pvt5a5d5z42egswfv7uscht7rv2rj3z4m8n3qp3w35592ydq88v4seuhn70OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output.
Witness itemswitness[0].length1@1351Number of witness stack items for input 0.
Schnorr signature lengthwitness[0][0].length1@13664CompactSize length of this witness item.
Schnorr signaturewitness[0][0]64@1374686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba264-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend.
Locktimelocktime4@20100: no time lock.
txidSHA256d without witness, reversed

d919e02a4adfd739ceef31d98803f0ddd24e1b1fa67b0fe572cdec42c1b384c9

wtxidSHA256d of everything, reversed

1e7d5c18e8982cd32f03a9c1409bb9c92d39dd4312cfffcf2ce9eb0c74e8ce30

Size
205 B
vsize
154 vB
137 + ⌈68 / 4⌉
Version
1
Locktime
0
Fee
7,915 grains
51.4 grains/vB
Total out
4.9564664 PRL

1 input

#0 Spends

33218153e2…9170553959 : 683

sequence 0xffffffff

  • Schnorr signature 4686c701…e7a86ba2 64 B

2 outputs

#0 2.9564664 PRL Taproot (P2TR, witness v1)

prl1p674s9jt2xs4amk6aq7ul867kcp8qwll5zsvpzzu6revewsu5z6eqv9d5z4

295,646,640 grains

#1 2 PRL Taproot (P2TR, witness v1)

prl1pvt5a5d5z42egswfv7uscht7rv2rj3z4m8n3qp3w35592ydq88v4seuhn70

200,000,000 grains

Runs in your browser · nothing is sent src/lib/tx.ts · real txs from mainnet

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.

A typical payment: 1 input, 2 outputs 205 bytes
01000000 00 01 01 5939557091bae792be66f26cbd83fc78f16a690a854109e8a1d115e253812133 ab020000 00 ffffffff 02 b0359f1100000000 22 5120d7ab02c96a342bdddb5d07b9f3ebd6c04e077ff41418110b9a1e5997439416b2 00c2eb0b00000000 22 512062e9da3682aab288392cf7218bafc36287288abb3ce200c5d1a50aa234073b2b 01 40 4686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba2 00000000
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.
txid
d919e02a4adfd739ceef31d98803f0ddd24e1b1fa67b0fe572cdec42c1b384c9
Size
205 bytes · 154 vbytes
Block
130,825
Fee
7,915 grains

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.

input 033218153…:683495,654,555 grainswitness64-byte signaturetransactiond919e02a…output 0 (change)295,646,640 grainsoutput 1 (payment)200,000,000 grainsfee: 7,915 grains (not written anywhere)
The shape of the payment above. The input points at an old output; the two new outputs lock fresh coins; the witness proves the right to spend.

What is the structure?

Every Pearl transaction has these fields, in this order:

A Pearl transaction, field by field (sizes in bytes)
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 scriptSig, 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 txid: 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 vbyte: 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.

2 inputs, 2 outputs 312 bytes
01000000 00 01 02 207decc85aaf210383704c39294c193864bf8e4255984abab5fe19a891ea0fc5 00000000 00 ffffffff d5da316cc9db4a367ce18ef27fb76809601a7fde2d111844962fc7584fceadf7 00000000 00 ffffffff 02 782d7c0700000000 22 51206f03b8c53fff74f0b22844a62fb29f822fda5f4e062d492f1d91bf567361a340 c07fdc0b00000000 22 5120e407fefe99e7ae5957da27b1565b4c9568fcd0a7c1b01ee8b79e694f0ec52fbd 01 40 bcdee9e8c70a956f0faf3f19324ff7595aa9d6d377010f12a392d5dfb8a20b05076090f11d7d6523f995c316c40b5c4c635853491a29dd5367e54e899e460638 01 40 9c9a3f1689bc718d7cbf2639e1433e7bb0f01896c7f2c14a565d515c41a5b5cd0e4a748978492d8dbda559088b66ef79003d421098cc25ef4ab05b39256790b8 00000000
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.
txid
091166043c8d93530171ca9e5ac883aaeae467934fbb8e4df1ea739c8d71b23e
Size
312 bytes · 212 vbytes
Block
130,822
Fee
10,650 grains

In this group

  1. 05.01 Inputs Which coins you are spending
  2. 05.02 Outputs An amount and a lock
  3. 05.03 Witness The proofs, kept apart from the rest
  4. 05.04 TXID A transaction's fingerprint, and its witness twin
  5. 05.05 Locktime and sequence Two small fields that say "not before"
  6. 05.06 Fees and vsize What a transaction pays, and how its size is measured
  7. 05.07 UTXO Coins are outputs nobody has spent yet
  8. 05.08 Coinbase transaction The transaction that creates new coins
  9. 05.09 Sighash What exactly a signature signs

The codex

Suggested

Up and down arrows move through the results, Enter opens one, Escape closes. Anywhere on the site, slash or Command K opens this search, and the square brackets [ and ] go to the previous and next page.