Changeset View
Changeset View
Standalone View
Standalone View
src/policy/policy.cpp
Show All 29 Lines | Amount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFeeIn) { | ||||
return 3 * dustRelayFeeIn.GetFee(nSize); | return 3 * dustRelayFeeIn.GetFee(nSize); | ||||
} | } | ||||
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, TxoutType &whichType) { | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
whichType = Solver(scriptPubKey, vSolutions); | whichType = Solver(scriptPubKey, vSolutions); | ||||
if (whichType == TX_NONSTANDARD) { | if (whichType == TxoutType::NONSTANDARD) { | ||||
return false; | return false; | ||||
} else if (whichType == TX_MULTISIG) { | } else if (whichType == TxoutType::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 == TxoutType::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; | ||||
Show All 27 Lines | for (const CTxIn &txin : tx.vin) { | ||||
} | } | ||||
if (!txin.scriptSig.IsPushOnly()) { | if (!txin.scriptSig.IsPushOnly()) { | ||||
reason = "scriptsig-not-pushonly"; | reason = "scriptsig-not-pushonly"; | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
unsigned int nDataOut = 0; | unsigned int nDataOut = 0; | ||||
txnouttype whichType; | TxoutType whichType; | ||||
for (const CTxOut &txout : tx.vout) { | for (const CTxOut &txout : tx.vout) { | ||||
if (!::IsStandard(txout.scriptPubKey, whichType)) { | if (!::IsStandard(txout.scriptPubKey, whichType)) { | ||||
reason = "scriptpubkey"; | reason = "scriptpubkey"; | ||||
return false; | return false; | ||||
} | } | ||||
if (whichType == TX_NULL_DATA) { | if (whichType == TxoutType::NULL_DATA) { | ||||
nDataOut++; | nDataOut++; | ||||
} else if ((whichType == TX_MULTISIG) && (!permit_bare_multisig)) { | } else if ((whichType == TxoutType::MULTISIG) && | ||||
(!permit_bare_multisig)) { | |||||
reason = "bare-multisig"; | reason = "bare-multisig"; | ||||
return false; | return false; | ||||
} else if (IsDust(txout, dust_relay_fee)) { | } else if (IsDust(txout, dust_relay_fee)) { | ||||
reason = "dust"; | reason = "dust"; | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
Show All 28 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.AccessCoin(in.prevout).GetTxOut(); | const CTxOut &prev = mapInputs.AccessCoin(in.prevout).GetTxOut(); | ||||
std::vector<std::vector<uint8_t>> vSolutions; | std::vector<std::vector<uint8_t>> vSolutions; | ||||
txnouttype whichType = Solver(prev.scriptPubKey, vSolutions); | TxoutType whichType = Solver(prev.scriptPubKey, vSolutions); | ||||
if (whichType == TX_NONSTANDARD) { | if (whichType == TxoutType::NONSTANDARD) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigOpCount, | int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigOpCount, | ||||
Show All 15 Lines |