Bitcoin ABC 0.30.5
P2P Digital Currency
Functions
policy.cpp File Reference
#include <coins.h>
#include <common/system.h>
#include <policy/policy.h>
#include <script/interpreter.h>
Include dependency graph for policy.cpp:

Go to the source code of this file.

Functions

Amount GetDustThreshold (const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
 
bool IsDust (const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
 
bool IsStandard (const CScript &scriptPubKey, const std::optional< unsigned > &max_datacarrier_bytes, TxoutType &whichType)
 
bool IsStandardTx (const CTransaction &tx, const std::optional< unsigned > &max_datacarrier_bytes, 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, uint32_t flags)
 Check transaction inputs to mitigate two potential denial-of-service attacks: More...
 
int64_t GetVirtualTransactionSize (int64_t nSize, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
 Compute the virtual transaction size (size, or more if sigChecks are too dense). More...
 
int64_t GetVirtualTransactionSize (const CTransaction &tx, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
 
int64_t GetVirtualTransactionInputSize (const CTxIn &txin, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
 

Function Documentation

◆ AreInputsStandard()

bool AreInputsStandard ( const CTransaction tx,
const CCoinsViewCache mapInputs,
uint32_t  flags 
)

Check transaction inputs to mitigate two potential denial-of-service attacks:

Check for standard transaction types.

  1. scriptSigs with extra data stuffed into them, not consumed by scriptPubKey (or P2SH script)
  2. P2SH scripts with a crazy number of expensive CHECKSIG/CHECKMULTISIG operations

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

Definition at line 145 of file policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDustThreshold()

Amount GetDustThreshold ( const CTxOut txout,
const CFeeRate dustRelayFeeIn 
)

"Dust" is defined in terms of dustRelayFee, which has units satoshis-per-kilobyte. If you'd pay more than 1/3 in fees to spend something, then we consider it dust. A typical spendable txout is 34 bytes big, and will need a CTxIn of at least 148 bytes to spend: so dust is a spendable txout less than 546*dustRelayFee/1000 (in satoshis).

Definition at line 14 of file policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVirtualTransactionInputSize()

int64_t GetVirtualTransactionInputSize ( const CTxIn txin,
int64_t  nSigChecks,
unsigned int  bytes_per_sigCheck 
)

Definition at line 176 of file policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVirtualTransactionSize() [1/2]

int64_t GetVirtualTransactionSize ( const CTransaction tx,
int64_t  nSigChecks,
unsigned int  bytes_per_sigCheck 
)

Definition at line 170 of file policy.cpp.

Here is the call graph for this function:

◆ GetVirtualTransactionSize() [2/2]

int64_t GetVirtualTransactionSize ( int64_t  nSize,
int64_t  nSigChecks,
unsigned int  bytes_per_sigCheck 
)

Compute the virtual transaction size (size, or more if sigChecks are too dense).

Definition at line 165 of file policy.cpp.

Here is the caller graph for this function:

◆ IsDust()

bool IsDust ( const CTxOut txout,
const CFeeRate dustRelayFeeIn 
)

Definition at line 34 of file policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsStandard()

bool IsStandard ( const CScript scriptPubKey,
const std::optional< unsigned > &  max_datacarrier_bytes,
TxoutType whichType 
)

Definition at line 38 of file policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsStandardTx()

bool IsStandardTx ( const CTransaction tx,
const std::optional< unsigned > &  max_datacarrier_bytes,
bool  permit_bare_multisig,
const CFeeRate dust_relay_fee,
std::string &  reason 
)

Check for standard transaction types.

Returns
True if all outputs (scriptPubKeys) use only standard transaction forms

Definition at line 66 of file policy.cpp.

Here is the call graph for this function: