The Policy Maker (src/policy/): Standardizing the Unstandardized
The Policy Maker (src/policy/): Standardizing the Unstandardized
In the world of Bitcoin, there is a big difference between what is Possible and what is Polite. The src/policy/ directory is where the Policy Maker lives. While the Consensus Guard (Section 14) defines the Law (the unbreakable rules of the universe), the Policy Maker defines the "Social Norms" of the network. He ensures that the network stays clean, efficient, and resistant to spam by refusing to handle transactions that are "weird" or "messy."
Standard vs. Non-Standard: The Postal Service Analogy
The Non-Coder Translation: Imagine the national Postal Service.
-
The Law (Consensus): The law says you can mail anything as long as it has a valid stamp and isn't a bomb.
-
The Policy (Standardness): The Post Office "Policy" might say: "We only accept envelopes that are rectangular and made of paper. We will not accept an envelope made of wet cardboard or a letter written on a coconut."
-
The Result: If you try to mail a coconut, the post office won't throw you in jail (it's not illegal), but they will refuse to carry it for you. You have to find a private courier (a miner) to carry it yourself.
In Bitcoin, a "Non-Standard" transaction is like a coconut. It follows the rules of math, but it's so weird that most nodes refuse to pass it along (relay it) to their neighbors.
The Minimum Relay Fee: The Anti-Spam Barrier
One of the Policy Maker's most important tools is the Minimum Relay Fee. This is defined in src/policy/policy.h.
// src/policy/policy.h - Defining the Minimum Relay Fee
/** Default for -minrelaytxfee, minimum relay fee for transactions */
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
The Non-Coder's Technical Deep Dive: Every transaction takes up space on your hard drive and bandwidth on your internet connection. If it were "Free" to send a transaction, a hacker could send 1 billion transactions for $0, which would clog the whole world's internet and crash every Bitcoin node. The Policy Maker says: "If you want me to tell my neighbors about your transaction, you must pay at least 1,000 satoshis per kilobyte." This tiny "Entrance Fee" makes it too expensive for anyone to spam the network, while still being cheap enough for a regular person to send money.
The "Dust" Limit: Cleaning Up the Pennies
The Policy Maker also hates "Dust." Dust is a transaction so small that the fee to spend it would be higher than the value of the coin itself (e.g., a coin worth $0.01 but costing $0.50 to move). If the network were full of dust, the "Librarian's" index cards (the UTXO set) would grow to a massive size, slowing down everyone's computer.
// src/policy/policy.cpp - The Dust Check
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee) {
// 1. Calculate how much it would cost to spend this coin in the future.
// 2. If the coin's value is lower than that cost, it is "Dust".
// 3. The Policy Maker refuses to relay dust to keep the ledger clean.
}
The Architect's Note: By refusing to relay dust, the Policy Maker ensures that the "Chainstate" (Section 4) remains lean and fast. It is a form of proactive maintenance that keeps the engine running smoothly for decades.
Script Policy: The "Safe" Smart Contracts
The Policy Maker also limits which "Smart Contracts" (Scripts) can be used. Even if the Scriptwriter (Section 11) could technically write a very complex 10,000-line script, the Policy Maker would say: "This is too complex and might have a hidden bug. I will only relay the 5 most common types of scripts."
-
P2PKH (Pay to Public Key Hash - the standard "1..." address)
-
SegWit ("bc1..." addresses) This conservatism protects the network from "Experimental" scripts that might accidentally crash nodes or cause a security vulnerability.
Why does Policy matter?
Policy is the "Social Layer" of Bitcoin. It allows the network to stay healthy without having to change the "Laws of Physics" (Consensus).
-
If a new type of spam attack appears, the developers can update the Policy Maker in a few days to block it.
-
Because it's only a "Policy," it doesn't cause the network to split or fork. Nodes that haven't updated yet just see the transactions differently, but they still agree on the final blocks.
Summary of Section 15
The src/policy/ directory is the "Janitor" and "Postmaster" of Bitcoin. By enforcing minimum fees, cleaning up dust, and standardizing which scripts are allowed, the Policy Maker ensures that the network remains clean, fast, and secure. He provides a flexible layer of defense that keeps the core engine running at peak performance, protecting it from the "Messiness" of the real world.
(End of sections 1-15. Appending more...)
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: