MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MarkReplaced

Method MarkReplaced

src/wallet/wallet.cpp:979–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977}
978
979bool CWallet::MarkReplaced(const Txid& originalHash, const Txid& newHash)
980{
981 LOCK(cs_wallet);
982
983 auto mi = mapWallet.find(originalHash);
984
985 // There is a bug if MarkReplaced is not called on an existing wallet transaction.
986 assert(mi != mapWallet.end());
987
988 CWalletTx& wtx = (*mi).second;
989
990 // Ensure for now that we're not overwriting data
991 assert(!wtx.mapValue.contains("replaced_by_txid"));
992
993 wtx.mapValue["replaced_by_txid"] = newHash.ToString();
994
995 // Refresh mempool status without waiting for transactionRemovedFromMempool or transactionAddedToMempool
996 RefreshMempoolStatus(wtx, chain());
997
998 WalletBatch batch(GetDatabase());
999
1000 bool success = true;
1001 if (!batch.WriteTx(wtx)) {
1002 WalletLogPrintf("%s: Updating batch tx %s failed\n", __func__, wtx.GetHash().ToString());
1003 success = false;
1004 }
1005
1006 NotifyTransactionChanged(originalHash, CT_UPDATED);
1007
1008 return success;
1009}
1010
1011void CWallet::SetSpentKeyState(WalletBatch& batch, const Txid& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
1012{

Callers 1

CommitTransactionFunction · 0.80

Calls 8

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

Tested by

no test coverage detected