|
|
@ -1383,9 +1383,20 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach |
|
|
|
if (!tx.IsCoinBase()) { |
|
|
|
txundo.vprevout.reserve(tx.vin.size()); |
|
|
|
BOOST_FOREACH(const CTxIn &txin, tx.vin) { |
|
|
|
txundo.vprevout.push_back(CTxInUndo()); |
|
|
|
bool ret = inputs.ModifyCoins(txin.prevout.hash)->Spend(txin.prevout, txundo.vprevout.back()); |
|
|
|
assert(ret); |
|
|
|
CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); |
|
|
|
unsigned nPos = txin.prevout.n; |
|
|
|
|
|
|
|
if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull()) |
|
|
|
assert(false); |
|
|
|
// mark an outpoint spent, and construct undo information
|
|
|
|
txundo.vprevout.push_back(CTxInUndo(coins->vout[nPos])); |
|
|
|
coins->Spend(nPos); |
|
|
|
if (coins->vout.size() == 0) { |
|
|
|
CTxInUndo& undo = txundo.vprevout.back(); |
|
|
|
undo.nHeight = coins->nHeight; |
|
|
|
undo.fCoinBase = coins->fCoinBase; |
|
|
|
undo.nVersion = coins->nVersion; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|