Skip to content

Commit 8b3868c

Browse files
committed
Switch CScriptCheck to use Coin instead of CCoins
1 parent c87b957 commit 8b3868c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/test/transaction_tests.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,18 +470,19 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
470470
for (int i=0; i<20; i++)
471471
threadGroup.create_thread(boost::bind(&CCheckQueue<CScriptCheck>::Thread, boost::ref(scriptcheckqueue)));
472472

473-
CCoins coins;
474-
coins.fCoinBase = false;
473+
std::vector<Coin> coins;
475474
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
476-
CTxOut txout;
477-
txout.nValue = 1000;
478-
txout.scriptPubKey = scriptPubKey;
479-
coins.vout.push_back(txout);
475+
Coin coin;
476+
coin.nHeight = 1;
477+
coin.fCoinBase = false;
478+
coin.out.nValue = 1000;
479+
coin.out.scriptPubKey = scriptPubKey;
480+
coins.emplace_back(std::move(coin));
480481
}
481482

482483
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
483484
std::vector<CScriptCheck> vChecks;
484-
const CTxOut& output = coins.vout[tx.vin[i].prevout.n];
485+
const CTxOut& output = coins[tx.vin[i].prevout.n].out;
485486
CScriptCheck check(output.scriptPubKey, output.nValue, tx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false, &txdata);
486487
vChecks.push_back(CScriptCheck());
487488
check.swap(vChecks.back());

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,16 +1116,16 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
11161116
if (fScriptChecks) {
11171117
for (unsigned int i = 0; i < tx.vin.size(); i++) {
11181118
const COutPoint &prevout = tx.vin[i].prevout;
1119-
const CCoins* coins = inputs.AccessCoins(prevout.hash);
1120-
assert(coins);
1119+
const Coin& coin = inputs.AccessCoin(prevout);
1120+
assert(!coin.IsPruned());
11211121

11221122
// We very carefully only pass in things to CScriptCheck which
11231123
// are clearly committed to by tx' witness hash. This provides
11241124
// a sanity check that our caching is not introducing consensus
11251125
// failures through additional data in, eg, the coins being
11261126
// spent being checked as a part of CScriptCheck.
1127-
const CScript& scriptPubKey = coins->vout[prevout.n].scriptPubKey;
1128-
const CAmount amount = coins->vout[prevout.n].nValue;
1127+
const CScript& scriptPubKey = coin.out.scriptPubKey;
1128+
const CAmount amount = coin.out.nValue;
11291129

11301130
// Verify signature
11311131
CScriptCheck check(scriptPubKey, amount, tx, i, flags, cacheStore, &txdata);

0 commit comments

Comments
 (0)