Changeset View
Changeset View
Standalone View
Standalone View
src/policy/policy.cpp
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | |||||
bool AreInputsStandard(const CTransaction &tx, | bool AreInputsStandard(const CTransaction &tx, | ||||
const CCoinsViewCache &mapInputs) { | const CCoinsViewCache &mapInputs) { | ||||
if (tx.IsCoinBase()) { | if (tx.IsCoinBase()) { | ||||
// Coinbases don't use vin normally. | // Coinbases don't use vin normally. | ||||
return true; | return true; | ||||
} | } | ||||
for (size_t i = 0; i < tx.vin.size(); i++) { | for (const CTxIn &in : tx.vin) { | ||||
const CTxOut &prev = mapInputs.GetOutputFor(tx.vin[i]); | const CTxOut &prev = mapInputs.GetOutputFor(in); | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
txnouttype whichType; | txnouttype whichType; | ||||
// get the scriptPubKey corresponding to this input: | // get the scriptPubKey corresponding to this input: | ||||
const CScript &prevScript = prev.scriptPubKey; | const CScript &prevScript = prev.scriptPubKey; | ||||
if (!Solver(prevScript, whichType, vSolutions)) { | if (!Solver(prevScript, whichType, vSolutions)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (whichType == TX_SCRIPTHASH) { | if (whichType == TX_SCRIPTHASH) { | ||||
std::vector<std::vector<uint8_t>> stack; | std::vector<std::vector<uint8_t>> stack; | ||||
// convert the scriptSig into a stack, so we can inspect the | // convert the scriptSig into a stack, so we can inspect the | ||||
// redeemScript | // redeemScript | ||||
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, | if (!EvalScript(stack, in.scriptSig, SCRIPT_VERIFY_NONE, | ||||
BaseSignatureChecker())) { | BaseSignatureChecker())) { | ||||
return false; | return false; | ||||
} | } | ||||
if (stack.empty()) { | if (stack.empty()) { | ||||
return false; | return false; | ||||
} | } | ||||
CScript subscript(stack.back().begin(), stack.back().end()); | CScript subscript(stack.back().begin(), stack.back().end()); | ||||
if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) { | if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE); | CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE); | ||||
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP; | uint32_t nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP; |