| 859 | } |
| 860 | |
| 861 | bool 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 | |
| 893 | void CWallet::SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) |
| 894 | { |
no test coverage detected