# Transaction

> The structure of a Pearl transaction, field by field, read from a real mainnet payment: version, inputs, outputs, witness and locktime.

Source: https://pearlcodex.com/technical/transaction/ · Last updated: 2026-10-21 · Checked against Pearl's source code at v1.5.5

A [transaction](https://pearlcodex.com/glossary/#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](https://pearlcodex.com/glossary/#input). Each input points at an [output](https://pearlcodex.com/glossary/#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](https://pearlcodex.com/glossary/#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.

_Interactive: Transaction decoder. Try it on the page: <https://pearlcodex.com/technical/transaction/>_

## 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 over or tap 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, offset 0    | 1 · int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.                                                                                                                   |
| Marker (`marker`)                                 | 1, offset 4    | 0x00 · Segwit marker (BIP-144): says witness data follows the outputs.                                                                                                                                                 |
| Flag (`flag`)                                     | 1, offset 5    | 0x01 · Witness flag; 0x01 is the only value Pearl accepts.                                                                                                                                                             |
| Input count (`vin.length`)                        | 1, offset 6    | 1 · CompactSize number of inputs.                                                                                                                                                                                      |
| Previous txid (`vin[0].txid`)                     | 32, offset 7   | 33218153e215d1a1e80941850a696af178fc83bd6cf266be92e7ba9170553959 · The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.                                             |
| Output index (`vin[0].vout`)                      | 4, offset 39   | 683 · Which output of that transaction is spent (uint32 LE).                                                                                                                                                           |
| scriptSig length (`vin[0].scriptSig.length`)      | 1, offset 43   | 0 · Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.                                                                                                                                   |
| Sequence (`vin[0].sequence`)                      | 4, offset 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, offset 48   | 2 · CompactSize number of outputs.                                                                                                                                                                                     |
| Amount (`vout[0].value`)                          | 8, offset 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, offset 57   | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[0].scriptPubKey`)           | 34, offset 58  | prl1p674s9jt2xs4amk6aq7ul867kcp8qwll5zsvpzzu6revewsu5z6eqv9d5z4 · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Amount (`vout[1].value`)                          | 8, offset 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, offset 100  | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[1].scriptPubKey`)           | 34, offset 101 | prl1pvt5a5d5z42egswfv7uscht7rv2rj3z4m8n3qp3w35592ydq88v4seuhn70 · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Witness items (`witness[0].length`)               | 1, offset 135  | 1 · Number of witness stack items for input 0.                                                                                                                                                                         |
| Schnorr signature length (`witness[0][0].length`) | 1, offset 136  | 64 · CompactSize length of this witness item.                                                                                                                                                                          |
| Schnorr signature (`witness[0][0]`)               | 64, offset 137 | 4686c7014749649b25555874c7772ecb7a44e85454893ed5888db11ebcdc82a22d74ce1a1671d02810f5ba1dca3277409e95a653ba9644099f7da26be7a86ba2 · 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime (`locktime`)                             | 4, offset 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.

_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:

| Field                                                                           | Size | Type        | Description                                                                |
| ------------------------------------------------------------------------------- | ---- | ----------- | -------------------------------------------------------------------------- |
| [version](https://pearlcodex.com/technical/transaction/#version)                | 4    | int32 LE    | Transaction version. Pearl wallets write 1.                                |
| [marker](https://pearlcodex.com/technical/transaction/#marker-and-flag)         | 1    | 00          | Segwit marker: witness data follows.                                       |
| [flag](https://pearlcodex.com/technical/transaction/#marker-and-flag)           | 1    | 01          | Segwit flag. 01 is the only value allowed.                                 |
| input count                                                                     | 1+   | CompactSize | How many inputs follow.                                                    |
| [txid](https://pearlcodex.com/technical/transaction/inputs/)                    | 32   | hash        | Input: the transaction being spent, byte-reversed.                         |
| [vout](https://pearlcodex.com/technical/transaction/inputs/)                    | 4    | uint32 LE   | Input: which of its outputs.                                               |
| [scriptSig length](https://pearlcodex.com/technical/transaction/inputs/)        | 1+   | CompactSize | Input: always `00` except in a coinbase.                                   |
| [sequence](https://pearlcodex.com/technical/transaction/locktime-and-sequence/) | 4    | uint32 LE   | Input: replace-by-fee signal and relative locks. Wallets write `ffffffff`. |
| output count                                                                    | 1+   | CompactSize | How many outputs follow.                                                   |
| [amount](https://pearlcodex.com/technical/transaction/outputs/)                 | 8    | int64 LE    | Output: value in grains.                                                   |
| [script length](https://pearlcodex.com/technical/transaction/outputs/)          | 1+   | CompactSize | Output: length of the locking script (34 for Taproot and P2MR).            |
| [locking script](https://pearlcodex.com/technical/script/)                      | var  | script      | Output: `5120…`, `5220…` or `6a…`. Nothing else is valid.                  |
| [witness](https://pearlcodex.com/technical/transaction/witness/)                | var  | stacks      | For each input: an item count, then each item with its length.             |
| [locktime](https://pearlcodex.com/technical/transaction/locktime-and-sequence/) | 4    | uint32 LE   | Earliest block height or time the transaction can be mined. Usually 0.     |

Numbers are stored [little-endian](https://pearlcodex.com/technical/general/byte-order/), smallest byte first. Counts and lengths are [CompactSize](https://pearlcodex.com/technical/general/compact-size/) 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](https://pearlcodex.com/technical/transaction/locktime-and-sequence/) 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](https://pearlcodex.com/glossary/#scriptsig), then a sequence number. The payment above spends output 683 of transaction `33218153…553959`. See [inputs](https://pearlcodex.com/technical/transaction/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](https://pearlcodex.com/technical/transaction/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](https://pearlcodex.com/technical/transaction/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](https://pearlcodex.com/technical/transaction/locktime-and-sequence/).

## How is a transaction identified?

By its [txid](https://pearlcodex.com/glossary/#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](https://pearlcodex.com/technical/transaction/txid/) 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](https://pearlcodex.com/glossary/#vbyte): this payment paid 7,915 grains, about 51.4 grains per vbyte. The [fees and vsize](https://pearlcodex.com/technical/transaction/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](https://pearlcodex.com/technical/transaction/inputs/))
- **Coinbase:** one input pointing at nothing, a height in the scriptSig, a witness commitment output. ([coinbase](https://pearlcodex.com/technical/transaction/coinbase/))
- **P2MR spend:** a witness with four items: two signatures, a 71-byte script and a 1-byte control block. ([P2MR](https://pearlcodex.com/technical/script/p2mr/))
- **OP_RETURN:** an output that carries 37 bytes of data and can never be spent. ([OP_RETURN](https://pearlcodex.com/technical/script/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, offset 0    | 1 · int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.                                                                                                                   |
| Marker (`marker`)                                 | 1, offset 4    | 0x00 · Segwit marker (BIP-144): says witness data follows the outputs.                                                                                                                                                 |
| Flag (`flag`)                                     | 1, offset 5    | 0x01 · Witness flag; 0x01 is the only value Pearl accepts.                                                                                                                                                             |
| Input count (`vin.length`)                        | 1, offset 6    | 2 · CompactSize number of inputs.                                                                                                                                                                                      |
| Previous txid (`vin[0].txid`)                     | 32, offset 7   | c50fea91a819feb5ba4a9855428ebf6438194c29394c70830321af5ac8ec7d20 · The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.                                             |
| Output index (`vin[0].vout`)                      | 4, offset 39   | 0 · Which output of that transaction is spent (uint32 LE).                                                                                                                                                             |
| scriptSig length (`vin[0].scriptSig.length`)      | 1, offset 43   | 0 · Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.                                                                                                                                   |
| Sequence (`vin[0].sequence`)                      | 4, offset 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, offset 48  | f7adce4f58c72f964418112dde7f1a600968b77ff28ee17c364adbc96c31dad5 · The transaction being spent, stored byte-reversed (internal order); shown here in normal display order.                                             |
| Output index (`vin[1].vout`)                      | 4, offset 80   | 0 · Which output of that transaction is spent (uint32 LE).                                                                                                                                                             |
| scriptSig length (`vin[1].scriptSig.length`)      | 1, offset 84   | 0 · Always 0 for non-coinbase inputs in Pearl: every spend uses the witness instead.                                                                                                                                   |
| Sequence (`vin[1].sequence`)                      | 4, offset 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, offset 89   | 2 · CompactSize number of outputs.                                                                                                                                                                                     |
| Amount (`vout[0].value`)                          | 8, offset 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, offset 98   | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[0].scriptPubKey`)           | 34, offset 99  | prl1pdupm33flla60pv3ggjnzlv5lsgha5h6wqck5jtcajxl4vump5dqq3mvacr · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Amount (`vout[1].value`)                          | 8, offset 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, offset 141  | 34 · CompactSize length of the locking script.                                                                                                                                                                         |
| Locking script (`vout[1].scriptPubKey`)           | 34, offset 142 | prl1pusrlal5eu7h9j476y7c4vk6vj450e598cxcpa69hne557rk9977skn6lrw · OP_1 OP_PUSHBYTES_32 \<output key Q>: a Taproot output.                                                                                              |
| Witness items (`witness[0].length`)               | 1, offset 176  | 1 · Number of witness stack items for input 0.                                                                                                                                                                         |
| Schnorr signature length (`witness[0][0].length`) | 1, offset 177  | 64 · CompactSize length of this witness item.                                                                                                                                                                          |
| Schnorr signature (`witness[0][0]`)               | 64, offset 178 | bcdee9e8c70a956f0faf3f19324ff7595aa9d6d377010f12a392d5dfb8a20b05076090f11d7d6523f995c316c40b5c4c635853491a29dd5367e54e899e460638 · 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Witness items (`witness[1].length`)               | 1, offset 242  | 1 · Number of witness stack items for input 1.                                                                                                                                                                         |
| Schnorr signature length (`witness[1][0].length`) | 1, offset 243  | 64 · CompactSize length of this witness item.                                                                                                                                                                          |
| Schnorr signature (`witness[1][0]`)               | 64, offset 244 | 9c9a3f1689bc718d7cbf2639e1433e7bb0f01896c7f2c14a565d515c41a5b5cd0e4a748978492d8dbda559088b66ef79003d421098cc25ef4ab05b39256790b8 · 64-byte BIP-340 signature (R.x ‖ s) with SIGHASH_DEFAULT: a Taproot key-path spend. |
| Locktime (`locktime`)                             | 4, offset 308  | 0 · 0: no time lock.                                                                                                                                                                                                   |

- **txid:** 091166043c8d93530171ca9e5ac883aaeae467934fbb8e4df1ea739c8d71b23e
- **Size:** 312 bytes · 212 vbytes
- **Block:** 130,822
- **Fee:** 10,650 grains

> **Pearl vs Bitcoin**
>
> - **Same format.** Pearl kept Bitcoin’s segwit serialization unchanged: no fields added or removed, same IDs.
> - **Only three output types** are valid at all: Taproot, P2MR and OP_RETURN. No P2PKH, P2SH or segwit v0, by consensus.
> - **Every spend uses the witness.** scriptSigs are empty, and the mempool rejects transactions without a witness.
> - **Version 1 is normal.** Pearl’s wallet writes version 1 (Bitcoin Core’s wallet writes 2), and version 3 is non-standard.
> - **vbytes, not weight units.** The numbers come out the same as Bitcoin’s weight ÷ 4, but Pearl only ever speaks vbytes.

## In this group

1. [Inputs](https://pearlcodex.com/technical/transaction/inputs/): Which coins you are spending
2. [Outputs](https://pearlcodex.com/technical/transaction/outputs/): An amount and a lock
3. [Witness](https://pearlcodex.com/technical/transaction/witness/): The proofs, kept apart from the rest
4. [TXID](https://pearlcodex.com/technical/transaction/txid/): A transaction’s fingerprint, and its witness twin
5. [Locktime and sequence](https://pearlcodex.com/technical/transaction/locktime-and-sequence/): Two small fields that say “not before”
6. [Fees and vsize](https://pearlcodex.com/technical/transaction/fees-and-vsize/): What a transaction pays, and how its size is measured
7. [UTXO](https://pearlcodex.com/technical/transaction/utxo/): Coins are outputs nobody has spent yet
8. [Coinbase transaction](https://pearlcodex.com/technical/transaction/coinbase/): The transaction that creates new coins
9. [Sighash](https://pearlcodex.com/technical/transaction/sighash/): What exactly a signature signs

## In short

- A transaction spends existing outputs (its inputs) and creates new ones (its outputs). The signatures that prove the right to spend sit in a separate witness section.
- The fields are: version (4 bytes), marker and flag (00 01), inputs, outputs, one witness per input, and locktime (4 bytes).
- Pearl kept Bitcoin’s segwit format byte for byte. What changed is what may go inside: only Taproot, P2MR and OP_RETURN outputs, and an empty scriptSig on every normal input.
- The txid is SHA256d of the transaction without its witness, shown byte-reversed. Size is measured in vbytes: witness bytes count a quarter.
- A typical Pearl payment (1 input, 2 outputs, a 64-byte signature) is 205 bytes, 154 vbytes.

## Read the code

- [Decoding a transaction, field by field](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/wire/msgtx.go#L570-L702) `node/wire/msgtx.go:570-702`
- [Encoding a transaction](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/wire/msgtx.go#L769-L836) `node/wire/msgtx.go:769-836`
- [The MsgTx, TxIn and TxOut structs (btcd's, but TxIn keeps its witness serialized)](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/wire/msgtx.go#L278-L450) `node/wire/msgtx.go:278-450`
- [CheckTransactionSanity: limits, amounts and the three output types](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L194-L302) `node/blockchain/validate.go:194-302`

## Sources

### Bitcoin standards

- [BIP-144: Segregated witness, peer services (the serialization)](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki)
- [BIP-141: Segregated witness (consensus layer)](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)

### Chain data

- [Payment d919e02a…84c9 on Pearl's explorer](https://explorer.pearlresearch.ai/tx/d919e02a4adfd739ceef31d98803f0ddd24e1b1fa67b0fe572cdec42c1b384c9)

### Other

- [learnmeabitcoin: Transaction](https://learnmeabitcoin.com/technical/transaction/)
