|
| 1 | +# Standardness Rules |
| 2 | + |
| 3 | +A transaction is considered "standard" if it passes a set of relay policy checks |
| 4 | +in addition to consensus rules. Nodes will not relay or mine non-standard |
| 5 | +transactions by default. These rules are local to the node and can be partially |
| 6 | +configured via command-line options. |
| 7 | + |
| 8 | +Most standardness checks are applied by `IsStandardTx()`, `AreInputsStandard()`, |
| 9 | +and `IsWitnessStandard()` in `src/policy/policy.cpp`. Additional checks (such as |
| 10 | +the minimum transaction size) are applied during mempool acceptance in |
| 11 | +`src/validation.cpp`. |
| 12 | + |
| 13 | +## Transaction-level checks |
| 14 | + |
| 15 | +- **Version**: Must be between 1 and 3 (inclusive). |
| 16 | +- **Weight**: Must not exceed 400,000 weight units (`MAX_STANDARD_TX_WEIGHT`). |
| 17 | +- **Non-witness size**: Must be at least 65 bytes (`MIN_STANDARD_TX_NONWITNESS_SIZE`), |
| 18 | + to prevent confusion with 64-byte Merkle tree inner nodes. |
| 19 | +- **ScriptSig**: Each input's scriptSig must be at most 1,650 bytes and contain |
| 20 | + only push operations. |
| 21 | + |
| 22 | +## Output-level checks |
| 23 | + |
| 24 | +- **Script type**: Each output's scriptPubKey must be a recognized standard type |
| 25 | + (P2PK, P2PKH, P2SH, P2WPKH, P2WSH, P2TR, multisig, `NULL_DATA`, or |
| 26 | + `ANCHOR`). Unknown or malformed scripts are rejected as `NONSTANDARD`. |
| 27 | +- **Data carrier (OP_RETURN)**: Outputs with `OP_RETURN` scripts |
| 28 | + (`NULL_DATA` type) are subject to a configurable size limit (see below). |
| 29 | + Multiple data carrier outputs are allowed; the limit applies to their |
| 30 | + aggregate scriptPubKey size. |
| 31 | +- **Bare multisig**: Bare multisig outputs (not wrapped in P2SH) can be |
| 32 | + disabled with `-permitbaremultisig=0`. |
| 33 | +- **Dust**: At most one output may be below the dust threshold. The dust |
| 34 | + threshold is derived from `-dustrelayfee` (default: 3,000 sat/kvB). |
| 35 | + |
| 36 | +## Input-level checks |
| 37 | + |
| 38 | +- **P2SH sigops**: A P2SH redeem script must not contain more than 15 sigops. |
| 39 | +- **BIP 54 sigops**: The total number of potentially executed legacy signature |
| 40 | + operations across the transaction must not exceed 2,500. |
| 41 | +- **Unknown witness programs**: Spending an output with an unknown witness |
| 42 | + version or unknown script type is non-standard. |
| 43 | +- **P2WSH limits**: Witness scripts are limited to 3,600 bytes, 100 stack |
| 44 | + items, and 80 bytes per stack item. |
| 45 | +- **Tapscript limits**: Stack items are limited to 80 bytes. Annexes are |
| 46 | + non-standard. |
| 47 | + |
| 48 | +## Configurable relay options |
| 49 | + |
| 50 | +| Option | Default | Description | |
| 51 | +|--------|---------|-------------| |
| 52 | +| `-datacarrier` | `1` | Relay and mine transactions with data carrier (`OP_RETURN`) outputs. Set to `0` to reject all data carrier transactions. | |
| 53 | +| `-datacarriersize` | `100000` | Maximum aggregate size (in bytes) of data-carrying `OP_RETURN` scriptPubKeys per transaction. Prior to v30.0, the default was `83`, which limited each `OP_RETURN` output to 80 bytes of payload plus the 3-byte script overhead. To restore the previous behavior, set `-datacarriersize=83`. | |
| 54 | +| `-permitbaremultisig` | `1` | Relay and mine transactions with bare (non-P2SH) multisig outputs. Set to `0` to reject them. | |
| 55 | +| `-dustrelayfee` | `3000` (sat/kvB) | Fee rate used to calculate the dust threshold. Outputs worth less than the cost to spend them at this fee rate are considered dust. | |
| 56 | +| `-bytespersigop` | `20` | Equivalent bytes per sigop in transactions for relay and mining. Affects the virtual size calculation. | |
| 57 | + |
| 58 | +These options affect only the local node's relay and mining policy. They do not |
| 59 | +affect consensus validation, and transactions rejected by these rules may still |
| 60 | +be included in blocks by miners with different policies. |
0 commit comments