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

Method MarkReplaced

src/wallet/wallet.cpp:902–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900}
901
902bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
903{
904 LOCK(cs_wallet);
905
906 auto mi = mapWallet.find(originalHash);
907
908 // There is a bug if MarkReplaced is not called on an existing wallet transaction.
909 assert(mi != mapWallet.end());
910
911 CWalletTx& wtx = (*mi).second;
912
913 // Ensure for now that we're not overwriting data
914 assert(wtx.mapValue.count("replaced_by_txid") == 0);
915
916 wtx.mapValue["replaced_by_txid"] = newHash.ToString();
917
918 WalletBatch batch(*database, "r+");
919
920 bool success = true;
921 if (!batch.WriteTx(wtx)) {
922 WalletLogPrintf("%s: Updating batch tx %s failed\n", __func__, wtx.GetHash().ToString());
923 success = false;
924 }
925
926 NotifyTransactionChanged(this, originalHash, CT_UPDATED);
927
928 return success;
929}
930
931bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
932{

Callers 1

CommitTransactionFunction · 0.80

Calls 7

WriteTxMethod · 0.80
NotifyTransactionChangedFunction · 0.50
findMethod · 0.45
endMethod · 0.45
countMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected