MCPcopy Create free account
hub / github.com/ElementsProject/elements / UpdateCoins

Function UpdateCoins

src/validation.cpp:1671–1693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1669}
1670
1671void 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
1695bool CScriptCheck::operator()() {
1696 const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;

Callers 2

ConnectBlockMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

AddCoinsFunction · 0.85
SetPeginSpentMethod · 0.80
emplace_backMethod · 0.80
SpendCoinMethod · 0.80
uint256Class · 0.70
IsCoinBaseMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68