| 900 | } |
| 901 | |
| 902 | bool 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 | |
| 931 | bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose) |
| 932 | { |
no test coverage detected