10 #include "../validation.h"
15 if (tx->nLockTime == 0)
19 if ((int64_t)tx->nLockTime < ((int64_t)tx->nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
21 for (
const CTxIn& txin : tx->vin)
29 unsigned int nSigOps = 0;
45 unsigned int nSigOps = 0;
46 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
60 return state.
DoS(10,
false, REJECT_INVALID,
"bad-txns-vin-empty");
64 return state.
DoS(10,
false, REJECT_INVALID,
"bad-txns-vout-empty");
69 error(
"%s: Transaction version (%d) too high. Max: %d", __func__, tx.
nVersion,
int(CTransaction::TxVersion::TOOHIGH) - 1),
70 REJECT_INVALID,
"bad-tx-version-too-high");
74 static_assert(MAX_BLOCK_SIZE_CURRENT >= MAX_TX_SIZE_AFTER_SAPLING,
"Max block size must be bigger than max TX size");
75 static_assert(MAX_TX_SIZE_AFTER_SAPLING > MAX_ZEROCOIN_TX_SIZE,
"New max TX size must be bigger than old max TX size");
76 const unsigned int nMaxSize = tx.
IsShieldedTx() ? MAX_TX_SIZE_AFTER_SAPLING : MAX_ZEROCOIN_TX_SIZE;
78 return state.
DoS(10,
error(
"tx oversize: %d > %d", tx.
GetTotalSize(), nMaxSize), REJECT_INVALID,
"bad-txns-oversize");
91 return state.
DoS(100,
false, REJECT_INVALID,
"bad-txns-vout-empty");
93 return state.
DoS(100,
false, REJECT_INVALID,
"bad-txns-vout-negative");
95 return state.
DoS(100,
false, REJECT_INVALID,
"bad-txns-vout-toolarge");
98 return state.
DoS(100,
false, REJECT_INVALID,
"bad-txns-txouttotal-toolarge");
101 if (!fColdStakingActive)
102 return state.
DoS(10,
false, REJECT_INVALID,
"cold-stake-inactive");
103 if (txout.
nValue < MIN_COLDSTAKING_AMOUNT)
104 return state.
DoS(100,
false, REJECT_INVALID,
"cold-stake-vout-toosmall");
108 std::set<COutPoint> vInOutPoints;
111 if (vInOutPoints.count(txin.
prevout))
112 return state.
DoS(100,
false, REJECT_INVALID,
"bad-txns-inputs-duplicate");
114 vInOutPoints.insert(txin.
prevout);
121 if (tx.
vin[0].scriptSig.size() < 2 || tx.
vin[0].scriptSig.size() > 150)
122 return state.
DoS(100,
false, REJECT_INVALID,
"bad-cb-length");
123 if (hasExchangeUTXOs)
124 return state.
DoS(100,
false, REJECT_INVALID,
"bad-exchange-address-in-cb");
128 return state.
DoS(10,
false, REJECT_INVALID,
"bad-txns-prevout-null");
int64_t CAmount
Amount in PIV (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
const Consensus::Params & GetConsensus() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to a Coin in the cache, or a pruned one if not found.
bool IsPayToScriptHash() const
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
bool IsPayToColdStaking() const
The basic transaction that is broadcasted on the network and contained in blocks.
bool HasZerocoinSpendInputs() const
bool HasExchangeAddr() const
bool IsQuorumCommitmentTx() const
bool IsShieldedTx() const
unsigned int GetTotalSize() const
Optional< SaplingTxData > sapData
std::vector< CTxOut > vout
An input of a transaction.
bool IsZerocoinSpend() const
An output of a transaction.
Capture information about block/transaction validation.
bool DoS(int level, bool ret=false, unsigned int chRejectCodeIn=0, std::string strRejectReasonIn="", bool corruptionIn=false, const std::string &strDebugMessageIn="")
CTxOut out
unspent transaction output
bool CheckTransaction(const CTransaction &tx, CValidationState &state, CAmount &nValueOut)
Context-independent validity checks.
bool ContextualCheckTransaction(const CTransaction &tx, CValidationState &state, const CChainParams &chainparams, const int nHeight, const bool isMined, bool isInitBlockDownload)
Check a transaction contextually against a set of consensus rules valid at a given block height.
Parameters that influence chain consensus.
bool MoneyRange(const CAmount &nValue) const
bool error(const char *fmt, const Args &... args)
int64_t GetAdjustedTime()
std::shared_ptr< const CTransaction > CTransactionRef
bool IsFinalTx(const CTransactionRef &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time.
bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fColdStakingActive)
Transaction validation functions.
bool ContextualCheckTransaction(const CTransactionRef &tx, CValidationState &state, const CChainParams &chainparams, int nHeight, bool isMined, bool fIBD)
Context-dependent validity checks.
unsigned int GetLegacySigOpCount(const CTransaction &tx)
Count ECDSA signature operations the old-fashioned (pre-0.6) way.
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &inputs)
Count ECDSA signature operations in pay-to-script-hash inputs.
bool ContextualCheckZerocoinTx(const CTransactionRef &tx, CValidationState &state, const Consensus::Params &consensus, int nHeight, bool isMined)