Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | if (IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE)) { | ||||
MarkDestinationsDirty(tx_destinations); | MarkDestinationsDirty(tx_destinations); | ||||
} | } | ||||
// Inserts only if not already there, returns tx inserted or tx found. | // Inserts only if not already there, returns tx inserted or tx found. | ||||
auto ret = | auto ret = | ||||
mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), | mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), | ||||
std::forward_as_tuple(this, tx)); | std::forward_as_tuple(this, tx)); | ||||
CWalletTx &wtx = (*ret.first).second; | CWalletTx &wtx = (*ret.first).second; | ||||
wtx.BindWallet(this); | |||||
bool fInsertedNew = ret.second; | bool fInsertedNew = ret.second; | ||||
bool fUpdated = update_wtx && update_wtx(wtx, fInsertedNew); | bool fUpdated = update_wtx && update_wtx(wtx, fInsertedNew); | ||||
if (fInsertedNew) { | if (fInsertedNew) { | ||||
wtx.m_confirm = confirm; | wtx.m_confirm = confirm; | ||||
wtx.nTimeReceived = chain().getAdjustedTime(); | wtx.nTimeReceived = chain().getAdjustedTime(); | ||||
wtx.nOrderPos = IncOrderPosNext(&batch); | wtx.nOrderPos = IncOrderPosNext(&batch); | ||||
wtx.m_it_wtxOrdered = | wtx.m_it_wtxOrdered = | ||||
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx)); | wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx)); | ||||
▲ Show 20 Lines • Show All 2,530 Lines • ▼ Show 20 Lines | AddToWallet(tx, {}, [&](CWalletTx &wtx, bool new_tx) { | ||||
wtx.fTimeReceivedIsTxTime = true; | wtx.fTimeReceivedIsTxTime = true; | ||||
wtx.fFromMe = true; | wtx.fFromMe = true; | ||||
return true; | return true; | ||||
}); | }); | ||||
// Notify that old coins are spent. | // Notify that old coins are spent. | ||||
for (const CTxIn &txin : tx->vin) { | for (const CTxIn &txin : tx->vin) { | ||||
CWalletTx &coin = mapWallet.at(txin.prevout.GetTxId()); | CWalletTx &coin = mapWallet.at(txin.prevout.GetTxId()); | ||||
coin.BindWallet(this); | coin.MarkDirty(); | ||||
NotifyTransactionChanged(this, coin.GetId(), CT_UPDATED); | NotifyTransactionChanged(this, coin.GetId(), CT_UPDATED); | ||||
} | } | ||||
// Get the inserted-CWalletTx from mapWallet so that the | // Get the inserted-CWalletTx from mapWallet so that the | ||||
// fInMempool flag is cached properly | // fInMempool flag is cached properly | ||||
CWalletTx &wtx = mapWallet.at(tx->GetId()); | CWalletTx &wtx = mapWallet.at(tx->GetId()); | ||||
if (!fBroadcastTransactions) { | if (!fBroadcastTransactions) { | ||||
▲ Show 20 Lines • Show All 1,610 Lines • Show Last 20 Lines |