aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-06-28 14:19:54 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-06-28 14:20:00 -0400
commitd3a5dbfd1f18b89dd990ee83ece7c1dd9ba94b1a (patch)
treed6a7361c523daada1ecc00600fdb9024353ffd71 /src/policy
parentd342a45ca74b4724aefed23770d19be7b6166bcc (diff)
parentfa32adf9dc25540ad27f5b82654c7057d7738627 (diff)
downloadbitcoin-d3a5dbfd1f18b89dd990ee83ece7c1dd9ba94b1a.tar.xz
Merge #19114: scripted-diff: TxoutType C++11 scoped enum class
fa32adf9dc25540ad27f5b82654c7057d7738627 scripted-diff: TxoutType C++11 scoped enum class (MarcoFalke) fa95a694c492b267e4038674fd3f338dd215ab48 doc: Update outdated txnouttype documentation (MarcoFalke) fa58469c770d8c935a86462634e4e8cd806aa6e3 rpc: Properly use underlying type in GetAllOutputTypes (MarcoFalke) fa41c657022b8f99c8e6718a0e33c5838c412a0b rpc: Simplify GetAllOutputTypes with the Join helper (MarcoFalke) Pull request description: Non-scoped enums can accidentally and silently decay into an integral type. Also, the symbol names of the keys are exported to the surrounding (usually global) namespace. Fix both issues by switching to an `enum class TxoutType` in a (mostly) scripted-diff. ACKs for top commit: practicalswift: ACK fa32adf9dc25540ad27f5b82654c7057d7738627 -- patch looks correct hebasto: re-ACK fa32adf9dc25540ad27f5b82654c7057d7738627, since fa5997bd6fc82e16b597ea96e3c5c665f1f174ab (https://github.com/bitcoin/bitcoin/pull/19114#pullrequestreview-421425198) rebased only (verified with `git range-diff`). Tree-SHA512: f42a9db47f9be89fa4bdd8d2fb05a16726286d8b12e3d87327b67d723f91c7d5a57deb4b2ddae9e1d16fee7a5f8c00828b6dc8909c5db680fc5e0a3cf07cd465
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/policy.cpp20
-rw-r--r--src/policy/policy.h2
2 files changed, 11 insertions, 11 deletions
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index 07d51c0088..c56abaf6c9 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -50,14 +50,14 @@ bool IsDust(const CTxOut& txout, const CFeeRate& 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<unsigned char> > vSolutions;
whichType = Solver(scriptPubKey, vSolutions);
- if (whichType == TX_NONSTANDARD) {
+ if (whichType == TxoutType::NONSTANDARD) {
return false;
- } else if (whichType == TX_MULTISIG) {
+ } else if (whichType == TxoutType::MULTISIG) {
unsigned char m = vSolutions.front()[0];
unsigned char n = vSolutions.back()[0];
// Support up to x-of-3 multisig txns as standard
@@ -65,7 +65,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
return false;
if (m < 1 || m > n)
return false;
- } else if (whichType == TX_NULL_DATA &&
+ } else if (whichType == TxoutType::NULL_DATA &&
(!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes)) {
return false;
}
@@ -110,16 +110,16 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
}
unsigned int nDataOut = 0;
- txnouttype whichType;
+ TxoutType whichType;
for (const CTxOut& txout : tx.vout) {
if (!::IsStandard(txout.scriptPubKey, whichType)) {
reason = "scriptpubkey";
return false;
}
- if (whichType == TX_NULL_DATA)
+ if (whichType == TxoutType::NULL_DATA)
nDataOut++;
- else if ((whichType == TX_MULTISIG) && (!permit_bare_multisig)) {
+ else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
reason = "bare-multisig";
return false;
} else if (IsDust(txout, dust_relay_fee)) {
@@ -163,10 +163,10 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
std::vector<std::vector<unsigned char> > vSolutions;
- txnouttype whichType = Solver(prev.scriptPubKey, vSolutions);
- if (whichType == TX_NONSTANDARD) {
+ TxoutType whichType = Solver(prev.scriptPubKey, vSolutions);
+ if (whichType == TxoutType::NONSTANDARD) {
return false;
- } else if (whichType == TX_SCRIPTHASH) {
+ } else if (whichType == TxoutType::SCRIPTHASH) {
std::vector<std::vector<unsigned char> > stack;
// convert the scriptSig into a stack, so we can inspect the redeemScript
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE))
diff --git a/src/policy/policy.h b/src/policy/policy.h
index 1561a41c5e..7f168ee20f 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -81,7 +81,7 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
-bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
+bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType);
/**
* Check for standard transaction types
* @return True if all outputs (scriptPubKeys) use only standard transaction forms