![]() |
Bitcoin Core 22.99.0
P2P Digital Currency
|
#include <consensus/consensus.h>
#include <policy/feerate.h>
#include <script/interpreter.h>
#include <script/standard.h>
#include <string>
Go to the source code of this file.
Functions | |
CAmount | GetDustThreshold (const CTxOut &txout, const CFeeRate &dustRelayFee) |
bool | IsDust (const CTxOut &txout, const CFeeRate &dustRelayFee) |
bool | IsStandard (const CScript &scriptPubKey, TxoutType &whichType) |
bool | IsStandardTx (const CTransaction &tx, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason) |
Check for standard transaction types. More... | |
bool | AreInputsStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs, bool taproot_active) |
Check for standard transaction types. More... | |
bool | IsWitnessStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs) |
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements These limits are adequate for multisignatures up to n-of-100 using OP_CHECKSIG, OP_ADD, and OP_EQUAL. More... | |
int64_t | GetVirtualTransactionSize (int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop) |
Compute the virtual transaction size (weight reinterpreted as bytes). More... | |
int64_t | GetVirtualTransactionSize (const CTransaction &tx, int64_t nSigOpCost, unsigned int bytes_per_sigop) |
int64_t | GetVirtualTransactionInputSize (const CTxIn &tx, int64_t nSigOpCost, unsigned int bytes_per_sigop) |
static int64_t | GetVirtualTransactionSize (const CTransaction &tx) |
static int64_t | GetVirtualTransactionInputSize (const CTxIn &tx) |
Variables | |
static const unsigned int | DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000 |
Default for -blockmaxweight, which controls the range of block weights the mining code will create. More... | |
static const unsigned int | DEFAULT_BLOCK_MIN_TX_FEE = 1000 |
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code. More... | |
static const unsigned int | MAX_STANDARD_TX_WEIGHT = 400000 |
The maximum weight for transactions we're willing to relay/mine. More... | |
static const unsigned int | MIN_STANDARD_TX_NONWITNESS_SIZE = 82 |
The minimum non-witness size for transactions we're willing to relay/mine (1 segwit input + 1 P2WPKH output = 82 bytes) More... | |
static const unsigned int | MAX_P2SH_SIGOPS = 15 |
Maximum number of signature check operations in an IsStandard() P2SH script. More... | |
static const unsigned int | MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5 |
The maximum number of sigops we're willing to relay/mine in a single tx. More... | |
static const unsigned int | DEFAULT_MAX_MEMPOOL_SIZE = 300 |
Default for -maxmempool, maximum megabytes of mempool memory usage. More... | |
static const unsigned int | DEFAULT_INCREMENTAL_RELAY_FEE = 1000 |
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement. More... | |
static const unsigned int | DEFAULT_BYTES_PER_SIGOP = 20 |
Default for -bytespersigop. More... | |
static const bool | DEFAULT_PERMIT_BAREMULTISIG = true |
Default for -permitbaremultisig. More... | |
static const unsigned int | MAX_STANDARD_P2WSH_STACK_ITEMS = 100 |
The maximum number of witness stack items in a standard P2WSH script. More... | |
static const unsigned int | MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80 |
The maximum size in bytes of each witness stack item in a standard P2WSH script. More... | |
static const unsigned int | MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE = 80 |
The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0) More... | |
static const unsigned int | MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600 |
The maximum size in bytes of a standard witnessScript. More... | |
static const unsigned int | MAX_STANDARD_SCRIPTSIG_SIZE = 1650 |
The maximum size of a standard ScriptSig. More... | |
static const unsigned int | DUST_RELAY_TX_FEE = 3000 |
Min feerate for defining dust. More... | |
static constexpr unsigned int | STANDARD_SCRIPT_VERIFY_FLAGS |
Standard script verification flags that standard transactions will comply with. More... | |
static constexpr unsigned int | STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS |
For convenience, standard but not mandatory verify flags. More... | |
static constexpr unsigned int | STANDARD_LOCKTIME_VERIFY_FLAGS |
Used as the flags parameter to sequence and nLocktime checks in non-consensus code. More... | |
static constexpr decltype(CTransaction::nVersion) | TX_MAX_STANDARD_VERSION {2} |
bool AreInputsStandard | ( | const CTransaction & | tx, |
const CCoinsViewCache & | mapInputs, | ||
bool | taproot_active | ||
) |
Check for standard transaction types.
[in] | mapInputs | Map of previous transactions that have outputs we're spending |
[in] | taproot_active | Whether or taproot consensus rules are active (used to decide whether spends of them are permitted) |
Check for standard transaction types.
Why bother? To avoid denial-of-service attacks; an attacker can submit a standard HASH... OP_EQUAL transaction, which will get accepted into blocks. The redemption script can be anything; an attacker could use a very expensive-to-check-upon-redemption script like: DUP CHECKSIG DROP ... repeated 100 times... OP_1
Note that only the non-witness portion of the transaction is checked here.
Definition at line 164 of file policy.cpp.
Definition at line 14 of file policy.cpp.
|
inlinestatic |
int64_t GetVirtualTransactionInputSize | ( | const CTxIn & | tx, |
int64_t | nSigOpCost, | ||
unsigned int | bytes_per_sigop | ||
) |
Definition at line 295 of file policy.cpp.
|
inlinestatic |
int64_t GetVirtualTransactionSize | ( | const CTransaction & | tx, |
int64_t | nSigOpCost, | ||
unsigned int | bytes_per_sigop | ||
) |
int64_t GetVirtualTransactionSize | ( | int64_t | nWeight, |
int64_t | nSigOpCost, | ||
unsigned int | bytes_per_sigop | ||
) |
Compute the virtual transaction size (weight reinterpreted as bytes).
Definition at line 285 of file policy.cpp.
Definition at line 53 of file policy.cpp.
Definition at line 58 of file policy.cpp.
bool IsStandardTx | ( | const CTransaction & | tx, |
bool | permit_bare_multisig, | ||
const CFeeRate & | dust_relay_fee, | ||
std::string & | reason | ||
) |
Check for standard transaction types.
Definition at line 81 of file policy.cpp.
bool IsWitnessStandard | ( | const CTransaction & | tx, |
const CCoinsViewCache & | mapInputs | ||
) |
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements These limits are adequate for multisignatures up to n-of-100 using OP_CHECKSIG, OP_ADD, and OP_EQUAL.
Also enforce a maximum stack item size limit and no annexes for tapscript spends.
Definition at line 201 of file policy.cpp.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Min feerate for defining dust.
Historically this has been based on the minRelayTxFee, however changing the dust limit changes which transactions are standard and should be done with care and ideally rarely. It makes sense to only increase the dust limit after prior releases were already not creating outputs below the new threshold
|
static |
Maximum number of signature check operations in an IsStandard() P2SH script.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
staticconstexpr |
Used as the flags parameter to sequence and nLocktime checks in non-consensus code.
|
staticconstexpr |
|
staticconstexpr |
Standard script verification flags that standard transactions will comply with.
However scripts violating these flags may still be present in valid blocks and we must accept those blocks.
|
staticconstexpr |