| 2183 | } |
| 2184 | |
| 2185 | void UpdateCoins(const CTransaction& tx, CValidationState& state, CCoinsViewCache& inputs, CTxUndo& txundo, int nHeight) |
| 2186 | { |
| 2187 | // mark inputs spent |
| 2188 | if (!tx.IsCoinBase()) { |
| 2189 | txundo.vprevout.reserve(tx.vin.size()); |
| 2190 | for (const CTxIn &txin : tx.vin) { |
| 2191 | CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); |
| 2192 | unsigned nPos = txin.prevout.n; |
| 2193 | |
| 2194 | if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull()) |
| 2195 | assert(false); |
| 2196 | // mark an outpoint spent, and construct undo information |
| 2197 | txundo.vprevout.push_back(CTxInUndo(coins->vout[nPos])); |
| 2198 | coins->Spend(nPos); |
| 2199 | if (coins->vout.size() == 0) { |
| 2200 | CTxInUndo &undo = txundo.vprevout.back(); |
| 2201 | undo.nHeight = coins->nHeight; |
| 2202 | undo.fCoinBase = coins->fCoinBase; |
| 2203 | undo.fCoinStake = coins->fCoinStake; |
| 2204 | undo.nVersion = coins->nVersion; |
| 2205 | } |
| 2206 | } |
| 2207 | } |
| 2208 | // add outputs |
| 2209 | inputs.ModifyNewCoins(tx.GetHash(), tx.IsCoinBase())->FromTx(tx,nHeight); |
| 2210 | } |
| 2211 | |
| 2212 | void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight) |
| 2213 | { |
no test coverage detected