Changeset View
Changeset View
Standalone View
Standalone View
src/policy/policy.cpp
Show All 34 Lines | |||||
} | } | ||||
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn) { | bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn) { | ||||
return (txout.nValue < GetDustThreshold(txout, dustRelayFeeIn)); | return (txout.nValue < GetDustThreshold(txout, dustRelayFeeIn)); | ||||
} | } | ||||
bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType) { | bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType) { | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
if (!Solver(scriptPubKey, whichType, vSolutions)) { | whichType = Solver(scriptPubKey, vSolutions); | ||||
return false; | |||||
} | |||||
if (whichType == TX_MULTISIG) { | if (whichType == TX_NONSTANDARD) { | ||||
return false; | |||||
} else if (whichType == TX_MULTISIG) { | |||||
uint8_t m = vSolutions.front()[0]; | uint8_t m = vSolutions.front()[0]; | ||||
uint8_t n = vSolutions.back()[0]; | uint8_t n = vSolutions.back()[0]; | ||||
// Support up to x-of-3 multisig txns as standard | // Support up to x-of-3 multisig txns as standard | ||||
if (n < 1 || n > 3) { | if (n < 1 || n > 3) { | ||||
return false; | return false; | ||||
} | } | ||||
if (m < 1 || m > n) { | if (m < 1 || m > n) { | ||||
return false; | return false; | ||||
} | } | ||||
} else if (whichType == TX_NULL_DATA) { | } else if (whichType == TX_NULL_DATA) { | ||||
if (!fAcceptDatacarrier) { | if (!fAcceptDatacarrier) { | ||||
return false; | return false; | ||||
} | } | ||||
unsigned nMaxDatacarrierBytes = | unsigned nMaxDatacarrierBytes = | ||||
gArgs.GetArg("-datacarriersize", MAX_OP_RETURN_RELAY); | gArgs.GetArg("-datacarriersize", MAX_OP_RETURN_RELAY); | ||||
if (scriptPubKey.size() > nMaxDatacarrierBytes) { | if (scriptPubKey.size() > nMaxDatacarrierBytes) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return whichType != TX_NONSTANDARD; | return true; | ||||
} | } | ||||
bool IsStandardTx(const CTransaction &tx, std::string &reason) { | bool IsStandardTx(const CTransaction &tx, std::string &reason) { | ||||
if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { | if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { | ||||
reason = "version"; | reason = "version"; | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (tx.IsCoinBase()) { | ||||
// Coinbases don't use vin normally. | // Coinbases don't use vin normally. | ||||
return true; | return true; | ||||
} | } | ||||
for (const CTxIn &in : tx.vin) { | for (const CTxIn &in : tx.vin) { | ||||
const CTxOut &prev = mapInputs.GetOutputFor(in); | const CTxOut &prev = mapInputs.GetOutputFor(in); | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
txnouttype whichType; | txnouttype whichType = Solver(prev.scriptPubKey, vSolutions); | ||||
// get the scriptPubKey corresponding to this input: | if (whichType == TX_NONSTANDARD) { | ||||
const CScript &prevScript = prev.scriptPubKey; | |||||
if (!Solver(prevScript, whichType, vSolutions)) { | |||||
return false; | return false; | ||||
} | } else 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, in.scriptSig, SCRIPT_VERIFY_NONE, | if (!EvalScript(stack, in.scriptSig, SCRIPT_VERIFY_NONE, | ||||
BaseSignatureChecker())) { | BaseSignatureChecker())) { | ||||
return false; | return false; | ||||
} | } | ||||
if (stack.empty()) { | if (stack.empty()) { | ||||
Show All 33 Lines |