| 1669 | } |
| 1670 | |
| 1671 | void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txundo, int nHeight) |
| 1672 | { |
| 1673 | // mark inputs spent |
| 1674 | if (!tx.IsCoinBase()) { |
| 1675 | txundo.vprevout.reserve(tx.vin.size()); |
| 1676 | for (size_t i = 0; i < tx.vin.size(); i++) { |
| 1677 | const CTxIn& txin = tx.vin[i]; |
| 1678 | if (txin.m_is_pegin) { |
| 1679 | const CTxInWitness& txinwit = tx.witness.vtxinwit[i]; |
| 1680 | std::pair<uint256, COutPoint> outpoint = std::make_pair(uint256(txinwit.m_pegin_witness.stack[2]), txin.prevout); |
| 1681 | inputs.SetPeginSpent(outpoint, true); |
| 1682 | // Dummy undo |
| 1683 | txundo.vprevout.emplace_back(); |
| 1684 | } else { |
| 1685 | txundo.vprevout.emplace_back(); |
| 1686 | bool is_spent = inputs.SpendCoin(txin.prevout, &txundo.vprevout.back()); |
| 1687 | assert(is_spent); |
| 1688 | } |
| 1689 | } |
| 1690 | } |
| 1691 | // add outputs |
| 1692 | AddCoins(inputs, tx, nHeight); |
| 1693 | } |
| 1694 | |
| 1695 | bool CScriptCheck::operator()() { |
| 1696 | const CScript &scriptSig = ptxTo->vin[nIn].scriptSig; |