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

Method MarkReplaced

src/wallet/wallet.cpp:861–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859}
860
861bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
862{
863 LOCK(cs_wallet);
864
865 auto mi = mapWallet.find(originalHash);
866
867 // There is a bug if MarkReplaced is not called on an existing wallet transaction.
868 assert(mi != mapWallet.end());
869
870 CWalletTx& wtx = (*mi).second;
871
872 // Ensure for now that we're not overwriting data
873 assert(wtx.mapValue.count("replaced_by_txid") == 0);
874
875 wtx.mapValue["replaced_by_txid"] = newHash.ToString();
876
877 // Refresh mempool status without waiting for transactionRemovedFromMempool
878 RefreshMempoolStatus(wtx, chain());
879
880 WalletBatch batch(GetDatabase());
881
882 bool success = true;
883 if (!batch.WriteTx(wtx)) {
884 WalletLogPrintf("%s: Updating batch tx %s failed\n", __func__, wtx.GetHash().ToString());
885 success = false;
886 }
887
888 NotifyTransactionChanged(originalHash, CT_UPDATED);
889
890 return success;
891}
892
893void CWallet::SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
894{

Callers 1

CommitTransactionFunction · 0.80

Calls 8

RefreshMempoolStatusFunction · 0.85
NotifyTransactionChangedFunction · 0.85
findMethod · 0.80
countMethod · 0.80
WriteTxMethod · 0.80
endMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected