| 977 | } |
| 978 | |
| 979 | bool 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 | |
| 1011 | void CWallet::SetSpentKeyState(WalletBatch& batch, const Txid& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) |
| 1012 | { |
no test coverage detected