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

Method IsSpent

src/wallet/wallet.cpp:633–650  ·  view source on GitHub ↗

* Outpoint is spent if any non-conflicted transaction * spends it: */

Source from the content-addressed store, hash-verified

631 * spends it:
632 */
633bool CWallet::IsSpent(const uint256& hash, unsigned int n) const
634{
635 const COutPoint outpoint(hash, n);
636 std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
637 range = mapTxSpends.equal_range(outpoint);
638
639 for (TxSpends::const_iterator it = range.first; it != range.second; ++it)
640 {
641 const uint256& wtxid = it->second;
642 std::map<uint256, CWalletTx>::const_iterator mit = mapWallet.find(wtxid);
643 if (mit != mapWallet.end()) {
644 int depth = GetTxDepthInMainChain(mit->second);
645 if (depth > 0 || (depth == 0 && !mit->second.isAbandoned()))
646 return true; // Spent
647 }
648 }
649 return false;
650}
651
652void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid, WalletBatch* batch)
653{

Callers 15

spend.cppFile · 0.45
GetAddressBalancesFunction · 0.45
interfaces.cppFile · 0.45
lockunspentFunction · 0.45
SignTransactionFunction · 0.45
operator==Function · 0.45
GetCoinMethod · 0.45
BatchWriteMethod · 0.45
SimulationTestFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
SetCoinsValueFunction · 0.45

Calls 3

findMethod · 0.80
isAbandonedMethod · 0.80
endMethod · 0.45

Tested by 10

operator==Function · 0.36
GetCoinMethod · 0.36
BatchWriteMethod · 0.36
SimulationTestFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
SetCoinsValueFunction · 0.36
GetCoinsMapEntryFunction · 0.36
operator==Function · 0.36
FUZZ_TARGET_INITFunction · 0.36
ContainsSpentInputFunction · 0.36