# Outputs

> A Pearl output is an 8-byte amount in grains and a locking script. Only three script shapes are valid at all: Taproot, P2MR and OP_RETURN. Dust is 333 grains.

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

An [output](https://pearlcodex.com/glossary/#output) is a coin: an amount, and a lock that says what it takes to spend it.

The amount is a whole number of [grains](https://pearlcodex.com/glossary/#grain), the smallest unit of PRL. The lock is a short [locking script](https://pearlcodex.com/glossary/#locking-script), usually the address of whoever is being paid, unwrapped into bytes. Once a transaction is in a block, each of its outputs sits in the ledger until a later transaction spends it.

## Try it

Pick the payment and hover its two outputs.

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

## What’s in an output?

| Field          | Size | Type        | Description                                                   |
| -------------- | ---- | ----------- | ------------------------------------------------------------- |
| amount         | 8    | int64 LE    | Value in grains. 1 PRL = 100,000,000 grains.                  |
| script length  | 1+   | CompactSize | Length of the locking script: `22` (34) for Taproot and P2MR. |
| locking script | var  | script      | The lock. On Pearl: `5120…`, `5220…` or `6a…`.                |

Here is the first output of the real payment from block 130,825:

**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

### Amount

- **Size:** 8 bytes
- **Type:** Signed integer (grains)
- **Format:** Little-endian
- **Range:** 0 to 21 billion PRL

`b0359f1100000000`, read smallest byte first, is 0x119f35b0 = 295,646,640 grains, or 2.95646640 PRL. The second output’s `00c2eb0b00000000` is 200,000,000 grains: exactly 2 PRL.

The consensus cap on an amount (and on the total of a transaction’s outputs) is 21 billion PRL, ten times the real supply limit of 2.1 billion. It’s a sanity check, not the supply rule.

### Locking script

- **Size:** 34 bytes for Taproot and P2MR
- **Type:** Script
- **Format:** Length-prefixed

`22` says 34 bytes follow: `51` (OP_1, witness version 1), `20` (push 32 bytes) and the 32-byte tweaked key `d7ab02c9…9416b2`. That is the address `prl1p674s9jt2…v9d5z4` in raw form; the [address page](https://pearlcodex.com/technical/keys/address/) shows the conversion.

## How does a wallet write an output?

From an address and an amount, in four mechanical steps. Here is the payment’s second output, 2 PRL to `prl1pvt5a5d5…euhn70`:

1. **Amount to grains**

   2 PRL × 100,000,000 = 200,000,000 grains = 0x0bebc200.

2. **Grains to 8 bytes, smallest first**

   `00 c2 eb 0b 00 00 00 00`.

3. **Address to locking script**

   Decode the bech32m address: version 1, program `62e9da36…073b2b`. Write `51` (OP_1), `20` (push 32), then the program.

4. **Prefix the length**

   34 bytes, so `22`. The output is 8 + 1 + 34 = 43 bytes.

Every Taproot and P2MR output is exactly 43 bytes this way, which is what lets wallets predict a transaction’s size before signing it.

## Which locking scripts are allowed?

Exactly three shapes. Pearl’s consensus code checks every output of every transaction, the coinbase included:

| Type                                                    | Bytes                  | Address  | Spent by                      |
| ------------------------------------------------------- | ---------------------- | -------- | ----------------------------- |
| [Taproot (P2TR)](https://pearlcodex.com/glossary/#p2tr) | `51 20` ‖ 32-byte key  | `prl1p…` | a signature, or a script path |
| [P2MR](https://pearlcodex.com/glossary/#p2mr)           | `52 20` ‖ 32-byte root | `prl1z…` | a script path only            |
| [OP_RETURN](https://pearlcodex.com/glossary/#op-return) | `6a` ‖ anything        | none     | nobody, ever                  |

`node/blockchain/validate.go`

```go
for i, txOut := range msgTx.TxOut {
	scriptClass := txscript.GetScriptClass(txOut.PkScript)
	if scriptClass != txscript.WitnessV1TaprootTy &&
		scriptClass != txscript.WitnessV2MerkleRootTy &&
		scriptClass != txscript.NullDataTy {
		str := fmt.Sprintf("transaction output %d has "+
			"unsupported script type %v", i, scriptClass)
		return ruleError(ErrScriptMalformed, str)
	}
```

Anything else makes the whole transaction invalid. These were all tested against Pearl’s own validation code:

| Output script                             | On Pearl                                       |
| ----------------------------------------- | ---------------------------------------------- |
| P2PKH `76a914…88ac`                       | invalid: “unsupported script type nonstandard” |
| P2SH `a914…87`                            | invalid                                        |
| segwit v0 `0014…`, `0020…`                | invalid                                        |
| witness v3 `5320…`                        | invalid                                        |
| witness v1 with a 20-byte program `5114…` | invalid                                        |
| pay-to-anchor `51024e73`                  | invalid                                        |
| bare multisig `51 21… 51 ae`              | invalid                                        |
| empty script                              | invalid                                        |
| `6a` alone, `6a` + 1,000 bytes, `6a ac`   | valid                                          |

> **Note: Consensus, not just policy**
>
> In Bitcoin, unusual outputs are valid in blocks and only “non-standard” for relay. On Pearl the three-type rule is part of consensus: a block containing one forbidden output is rejected by every node.

## What’s the smallest output?

As far as consensus goes, 0 grains. But nodes won’t relay a transaction that creates a Taproot or P2MR output below the [dust](https://pearlcodex.com/glossary/#dust) limit, 333 grains, because such an output is worth so little that spending it would eat a large share of its value in fees.

The number comes from a formula: three times the cost, at the minimum relay fee of 1 grain per vbyte, of the output plus a typical input that would later spend it.

$$
3 \times \big(\underbrace{43}_{\text{output}} + \underbrace{41}_{\text{input}} + \underbrace{\lceil 107/4 \rceil}_{\text{witness}}\big) = 3 \times (43 + 41 + 27) = 333
$$

A 332-grain Taproot output is rejected by the mempool (“payment is dust: 332”); 333 passes. OP_RETURN outputs are exempt. Dust is [policy](https://pearlcodex.com/glossary/#standardness): a miner could still put a 1-grain output in a block.

## Which output is the change?

Nothing in the bytes says. [Change](https://pearlcodex.com/glossary/#change) is just another output, locked to an address the sender’s wallet controls.

Pearl’s wallet picks the change position at random, so it isn’t always last. In the payment above, the round 2 PRL output (second) is almost certainly the payment, and the first output, 2.95646640 PRL, the change. Observers use guesses like that; the protocol doesn’t care.

## What happens to an output next?

- **Taproot and P2MR outputs** join the [UTXO set](https://pearlcodex.com/glossary/#utxo) under the name `txid:index`, here `d919e02a…:0` and `d919e02a…:1`, until an input spends them.
- **OP_RETURN outputs** never enter the UTXO set. Nodes can forget them at once, which is why they’re the place for data.

> **Pearl vs Bitcoin**
>
> - Same 8-byte amount and length-prefixed script.
> - Only three locking scripts are valid, by consensus. Every Pearl output is either 43 bytes (Taproot, P2MR) or an OP_RETURN.
> - Dust for Taproot outputs is 333 grains, where Bitcoin Core uses 330 satoshis, because Pearl rounds the witness estimate up.
> - Pearl’s amount cap, 21 billion PRL, is ten times its supply. Bitcoin’s MAX_MONEY equals its supply.

## In short

- An output is an 8-byte little-endian amount in grains followed by a locking script with its length.
- Pearl’s consensus accepts exactly three locking scripts: 51 20 ‖ 32 bytes (Taproot), 52 20 ‖ 32 bytes (P2MR), or anything starting 6a (OP_RETURN).
- Any other output, including Bitcoin’s P2PKH, P2SH and segwit v0 shapes, makes the whole transaction invalid, coinbase included.
- Relay policy refuses Taproot and P2MR outputs below 333 grains (dust). OP_RETURN outputs are exempt and never enter the UTXO set.
- Nothing marks which output is change. Pearl’s wallet puts its change output at a random position.

## Read the code

- [Only P2TR, P2MR and OP_RETURN outputs; amount limits](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L218-L264) `node/blockchain/validate.go:218-264`
- [GetScriptClass recognizes exactly three forms](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/txscript/standard.go#L205-L231) `node/txscript/standard.go:205-231`
- [The dust threshold](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/mempool/policy.go#L137-L209) `node/mempool/policy.go:137-209`
- [Grains per PRL, and MaxGrain (21 billion PRL)](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/btcutil/const.go#L7-L16) `node/btcutil/const.go:7-16`
- [The wallet randomizes the change position](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/wallet/wallet/createtx.go#L260-L265) `wallet/wallet/createtx.go:260-265`

## Sources

### Bitcoin standards

- [BIP-141: Segregated witness (witness programs)](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)
- [BIP-341: Taproot](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki)

### Other

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