Skip to content

Commit cd38482

Browse files
committed
doc: add standardness policy documentation and improve -datacarriersize help
Add doc/policy/standardness.md documenting the transaction standardness rules enforced during relay and mining. This covers transaction-level, output-level, and input-level checks, along with a table of configurable relay options (-datacarrier, -datacarriersize, -permitbaremultisig, -dustrelayfee, -bytespersigop). Also update the -datacarriersize help text to mention that setting it to 83 restores the pre-v30.0 behavior.
1 parent 8b70ed6 commit cd38482

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

doc/policy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ contents. Policy is *not* applied to transactions in blocks.
99

1010
This documentation is not an exhaustive list of all policy rules.
1111

12+
- [Standardness Rules](standardness.md)
1213
- [Mempool Design and Limits](mempool-design.md)
1314
- [Mempool Replacements](mempool-replacements.md)
1415
- [Packages](packages.md)

doc/policy/standardness.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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.

src/init.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,9 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
677677
argsman.AddArg("-datacarrier", strprintf("Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
678678
argsman.AddArg("-datacarriersize",
679679
strprintf("Relay and mine transactions whose data-carrying raw scriptPubKeys in aggregate "
680-
"are of this size or less, allowing multiple outputs (default: %u)",
680+
"are of this size or less, allowing multiple outputs (default: %u). "
681+
"Set to 83 to restore the pre-v30.0 behavior of a single OP_RETURN "
682+
"output with at most 80 bytes of payload.",
681683
MAX_OP_RETURN_RELAY),
682684
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
683685
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,

0 commit comments

Comments
 (0)