Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 946 Lines • ▼ Show 20 Lines | |||||
void CWallet::MarkDirty() { | void CWallet::MarkDirty() { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
for (std::pair<const uint256, CWalletTx> &item : mapWallet) { | for (std::pair<const uint256, CWalletTx> &item : mapWallet) { | ||||
item.second.MarkDirty(); | item.second.MarkDirty(); | ||||
} | } | ||||
} | } | ||||
bool CWallet::MarkReplaced(const uint256 &originalHash, | |||||
const uint256 &newHash) { | |||||
LOCK(cs_wallet); | |||||
auto mi = mapWallet.find(originalHash); | |||||
// There is a bug if MarkReplaced is not called on an existing wallet | |||||
// transaction. | |||||
assert(mi != mapWallet.end()); | |||||
CWalletTx &wtx = (*mi).second; | |||||
// Ensure for now that we're not overwriting data. | |||||
assert(wtx.mapValue.count("replaced_by_txid") == 0); | |||||
wtx.mapValue["replaced_by_txid"] = newHash.ToString(); | |||||
CWalletDB walletdb(*dbw, "r+"); | |||||
bool success = true; | |||||
if (!walletdb.WriteTx(wtx)) { | |||||
LogPrintf("%s: Updating walletdb tx %s failed", __func__, | |||||
wtx.GetId().ToString()); | |||||
success = false; | |||||
} | |||||
NotifyTransactionChanged(this, originalHash, CT_UPDATED); | |||||
return success; | |||||
} | |||||
bool CWallet::AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose) { | bool CWallet::AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose) { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
CWalletDB walletdb(*dbw, "r+", fFlushOnClose); | CWalletDB walletdb(*dbw, "r+", fFlushOnClose); | ||||
uint256 hash = wtxIn.GetId(); | uint256 hash = wtxIn.GetId(); | ||||
// Inserts only if not already there, returns tx inserted or tx found. | // Inserts only if not already there, returns tx inserted or tx found. | ||||
▲ Show 20 Lines • Show All 3,542 Lines • Show Last 20 Lines |