aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/tx_verify.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-06-05 20:16:18 -0400
committerMatt Corallo <git@bluematt.me>2017-06-09 13:10:08 -0400
commitf58349ca856fc59704fb78c19267b1cef1c9650b (patch)
treeed74b731c21fbbcc7abbcc97d320471e74348cbc /src/consensus/tx_verify.cpp
parent3533fb4d33ecc94a789cb5d4489da22a68fb2168 (diff)
Restore some assert semantics in sigop cost calculations
There are some similar asserts which are left removed in policy and ATMP (policy code being broken isn't a huge deal, but if we fail to verify some consensus rules, we should most definitely crash).
Diffstat (limited to 'src/consensus/tx_verify.cpp')
-rw-r--r--src/consensus/tx_verify.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp
index bf68f8754b..0671cbc132 100644
--- a/src/consensus/tx_verify.cpp
+++ b/src/consensus/tx_verify.cpp
@@ -126,7 +126,9 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
unsigned int nSigOps = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
- const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
+ const Coin& coin = inputs.AccessCoin(tx.vin[i].prevout);
+ assert(!coin.IsSpent());
+ const CTxOut &prevout = coin.out;
if (prevout.scriptPubKey.IsPayToScriptHash())
nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig);
}
@@ -146,7 +148,9 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
- const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
+ const Coin& coin = inputs.AccessCoin(tx.vin[i].prevout);
+ assert(!coin.IsSpent());
+ const CTxOut &prevout = coin.out;
nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, &tx.vin[i].scriptWitness, flags);
}
return nSigOps;