# Fees and vsize

> A Pearl fee is inputs minus outputs, priced per virtual byte. How vsize discounts the witness, the 1 grain/vB floor, real fee rates and size limits.

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

A [fee](https://pearlcodex.com/glossary/#fee) is the part of the inputs that no output claims. The miner who includes the transaction collects it, on top of the new coins in the block reward.

Nothing in a transaction says “fee”. You find it by subtraction. And since block space is what’s scarce, fees are compared per unit of size: [grains per virtual byte](https://pearlcodex.com/glossary/#fee-rate). This page explains both numbers and the limits around them.

## Try it

Pick a transaction shape and a fee rate and see what it costs.

_Interactive: Fee calculator. Try it on the page: <https://pearlcodex.com/technical/transaction/fees-and-vsize/>_

## Where is the fee?

In the gap between inputs and outputs. Take the real payment from block 130,825:

|                        | Grains        |
| ---------------------- | ------------- |
| Input: `33218153…:683` | 495,654,555   |
| Output 0 (change)      | − 295,646,640 |
| Output 1 (payment)     | − 200,000,000 |
| **Fee**                | **7,915**     |

The input’s value isn’t in the transaction either; nodes look it up in the [UTXO set](https://pearlcodex.com/technical/transaction/utxo/). That’s why a node needs the outputs being spent before it can even tell what fee a transaction pays.

## What is vsize?

A size in which witness bytes count a quarter. Pearl calls it virtual size, measured in [vbytes](https://pearlcodex.com/glossary/#vbyte):

$$
\text{vsize} = \text{base size} + \left\lceil \frac{\text{witness size}}{4} \right\rceil
$$

- **Base size** is the transaction without marker, flag and witness: the bytes that make the txid.
- **Witness size** is everything else: the marker and flag (2 bytes) plus all witness stacks.
- The division rounds up, so even 1 to 3 witness bytes cost a full vbyte.

`node/blockchain/vsize.go`

```go
func CalcVsize(baseSize int, witnessSize int) int64 {
	return int64(baseSize + (witnessSize+WitnessScaleFactor-1)/WitnessScaleFactor)
}
```

For the payment: 137 base bytes + ⌈68 ÷ 4⌉ = 137 + 17 = **154 vbytes**, at 7,915 ÷ 154 = **51.4 grains per vbyte**.

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

The highlighted bytes, plus the `00 01` after the version, are the 68 discounted ones.

### Real transactions, measured

| Transaction                                                                       | Size | Base | Witness | vsize | Fee    | Rate |
| --------------------------------------------------------------------------------- | ---- | ---- | ------- | ----- | ------ | ---- |
| [Payment](https://pearlcodex.com/technical/transaction/), 1 in, 2 out             | 205  | 137  | 68      | 154   | 7,915  | 51.4 |
| [Payment](https://pearlcodex.com/technical/transaction/inputs/), 2 in, 2 out      | 312  | 178  | 134     | 212   | 10,650 | 50.2 |
| [OP_RETURN](https://pearlcodex.com/technical/script/op-return/), 1 in, 3 out      | 253  | 185  | 68      | 202   | 10,200 | 50.5 |
| [P2MR funding](https://pearlcodex.com/technical/script/p2mr/), 2 in, 2 out        | 312  | 178  | 134     | 212   | 10,803 | 51.0 |
| [P2MR 2-of-2 spend](https://pearlcodex.com/technical/script/p2mr/), 1 in, 3 out   | 387  | 180  | 207     | 232   | 1,000  | 4.3  |
| [Coinbase](https://pearlcodex.com/technical/transaction/coinbase/), block 130,825 | 216  | 180  | 36      | 189   | none   | –    |

Sizes in bytes, fees in grains, rates in grains per vbyte. The P2MR spend shows the discount at work: 207 bytes of witness, two signatures and a script, cost only 52 vbytes.

## Why discount the witness?

Two reasons, both inherited from Bitcoin’s segwit:

- **Witness data can be dropped later.** Once a block is deep in the chain, nodes don’t need old signatures to know the current set of coins. Base data, which defines that set, is the expensive part.
- **It makes spending cheaper than creating.** Inputs carry witnesses; outputs don’t. Discounting witnesses nudges wallets to consolidate coins rather than fragment them.

> **Note: No weight units**
>
> Bitcoin defines “weight” (3 × base + total) and caps blocks at 4,000,000 weight units. Pearl has no weight constant at all: its code, its limits and its RPC results speak vbytes only. The two agree: weight ÷ 4, rounded up, always equals Pearl’s vsize. The payment above is 616 weight units in Bitcoin terms, and 616 ÷ 4 = 154.

## How does a wallet know the size before signing?

Because every piece of a Pearl key-path spend has a fixed size. An input is 41 base bytes plus a 66-byte witness (count, length, 64-byte signature); a Taproot or P2MR output is 43 bytes; the rest is 10 bytes plus the 2-byte marker and flag. With n inputs and m outputs (under 253 of each):

$$
\text{vsize} = 10 + 41n + 43m + \left\lceil \frac{2 + 66n}{4} \right\rceil
$$

One input, two outputs: 10 + 41 + 86 + 17 = 154. Two and two: 10 + 82 + 86 + 34 = 212. Both match the real transactions in the table.

## What’s the minimum fee?

1 grain per vbyte. Nodes won’t relay or mine a transaction paying less; the payment above would have needed at least 154 grains.

The code calls this `DefaultMinRelayTxFee = 1000`, “in Grain/1000 bytes”. Read “bytes” as vbytes: Pearl’s mempool computes every fee rate as fee × 1,000 ÷ vsize, and so does the wallet. Two unit traps follow:

- **“Per kB” means per 1,000 vbytes**, everywhere in Pearl’s node and wallet.
- **RPC fee arguments are in PRL, not grains.** Oyster’s `feerateperkb` of 0.00001 PRL/kB = 1,000 grains per 1,000 vbytes = 1 grain per vbyte, which is oystercli’s default. The plain RPC send calls have no default: the caller must pass a rate.

## What do transactions actually pay?

A snapshot, not advice. On 2026-10-20 Pearl’s Blockbook estimated, in PRL per 1,000 vbytes:

| To confirm within  | Estimate   | Grains per vbyte |
| ------------------ | ---------- | ---------------- |
| 1 block            | 0.00051294 | about 51.3       |
| 2 blocks           | 0.00002432 | about 2.4        |
| 3 blocks           | 0.00001005 | about 1.0        |
| 6, 12 or 25 blocks | 0.00001    | 1.0 (the floor)  |

Most payments in recent blocks paid about 50 to 51 grains per vbyte, matching the 1-block estimate. Some paid far less and still confirmed: the P2MR spend above paid 4.3. More than half of recent blocks carried only their coinbase, so space is rarely short.

Remember that Pearl’s wallet doesn’t signal [replace-by-fee](https://pearlcodex.com/technical/transaction/locktime-and-sequence/), so its transactions can’t be replaced by a higher-fee version after sending.

## How big can things get?

- **Block:** 1,000,000 vB certificate not counted
- **Standard transaction:** 100,000 vB relay policy
- **Any transaction:** 1,000,000 vB consensus
- **Minimum relay fee:** 1 grain/vB 1,000 grains per 1,000 vB
- **Dust (Taproot, P2MR):** 333 grains smallest relayed output
- **Unconfirmed chain:** 25 txs and 101,000 vB of ancestors

A block’s vsize counts its 108-byte header, its transactions and their witnesses (discounted), but not the \~60 KB proof certificate that travels with it. There’s also a floor: Pearl’s mempool rejects transactions whose base size is under 65 bytes.

> **Pearl vs Bitcoin**
>
> - **Same arithmetic, different words.** Pearl’s 1,000,000-vbyte block equals Bitcoin’s 4,000,000 weight units, and every vsize matches. Pearl just never mentions weight.
> - **Same relay floor** as Bitcoin Core’s long-standing default, 1 unit per vbyte, but “kB” in Pearl’s code means 1,000 vbytes.
> - **Dust is 333 grains** for Taproot outputs, three more than Bitcoin’s 330.
> - **No fee bumping by default**, because Pearl’s wallet doesn’t signal RBF.

## In short

- The fee is never written in a transaction: it is the total of the inputs minus the total of the outputs, and the miner keeps it.
- Size is measured in virtual bytes: vsize = base size + ⌈witness bytes ÷ 4⌉. Witness bytes, including the marker and flag, count a quarter.
- A one-input, two-output Taproot payment is 154 vbytes. The real one on this page paid 7,915 grains: 51.4 grains per vbyte.
- Nodes relay transactions paying at least 1 grain per vbyte. Fee settings quoted “per kB” in Pearl’s code mean per 1,000 vbytes.
- A block holds at most 1,000,000 vbytes (the certificate doesn’t count); a standard transaction at most 100,000.

## Read the code

- [vsize = base + ⌈witness ÷ 4⌉; MaxBlockVsize = 1,000,000](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/vsize.go#L13-L73) `node/blockchain/vsize.go:13-73`
- [Minimum relay fee: 1,000 grains per 1,000 vbytes](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/mempool/policy.go#L45-L101) `node/mempool/policy.go:45-101`
- [Max standard transaction: 100,000 vbytes](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/mempool/policy.go#L22-L24) `node/mempool/policy.go:22-24`
- [FeePerKB is fee × 1,000 ÷ vsize](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/mempool/mempool.go#L604) `node/mempool/mempool.go:604`
- [oystercli's default fee rate: 1e-5 PRL/kB](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/wallet/cmd/oystercli/send.go#L17-L22) `wallet/cmd/oystercli/send.go:17-22`

## Sources

### Bitcoin standards

- [BIP-141: Segregated witness (the witness discount)](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)

### Chain data

- [Pearl Blockbook fee estimate (estimatefee), snapshot 2026-10-20](https://blockbook.pearlresearch.ai/api/v2/estimatefee/1)

### Other

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