Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 3,658 Lines • ▼ Show 20 Lines | bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn, | ||||
// Before we return success, we assume any change key will be used to | // Before we return success, we assume any change key will be used to | ||||
// prevent accidental re-use. | // prevent accidental re-use. | ||||
reservedest.KeepDestination(); | reservedest.KeepDestination(); | ||||
return true; | return true; | ||||
} | } | ||||
bool CWallet::CommitTransaction( | void CWallet::CommitTransaction( | ||||
CTransactionRef tx, mapValue_t mapValue, | CTransactionRef tx, mapValue_t mapValue, | ||||
std::vector<std::pair<std::string, std::string>> orderForm, | std::vector<std::pair<std::string, std::string>> orderForm, | ||||
TxValidationState &state) { | TxValidationState &state) { | ||||
auto locked_chain = chain().lock(); | auto locked_chain = chain().lock(); | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
CWalletTx wtxNew(this, std::move(tx)); | CWalletTx wtxNew(this, std::move(tx)); | ||||
wtxNew.mapValue = std::move(mapValue); | wtxNew.mapValue = std::move(mapValue); | ||||
Show All 14 Lines | for (const CTxIn &txin : wtxNew.tx->vin) { | ||||
coin.BindWallet(this); | coin.BindWallet(this); | ||||
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(wtxNew.GetId()); | CWalletTx &wtx = mapWallet.at(wtxNew.GetId()); | ||||
if (fBroadcastTransactions) { | if (!fBroadcastTransactions) { | ||||
// Don't submit tx to the mempool | |||||
return; | |||||
} | |||||
std::string err_string; | std::string err_string; | ||||
if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) { | if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) { | ||||
WalletLogPrintf("CommitTransaction(): Transaction cannot be " | WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast " | ||||
"broadcast immediately, %s\n", | "immediately, %s\n", | ||||
err_string); | err_string); | ||||
// TODO: if we expect the failure to be long term or permanent, | // TODO: if we expect the failure to be long term or permanent, instead | ||||
// instead delete wtx from the wallet and return failure. | // delete wtx from the wallet and return failure. | ||||
} | } | ||||
} | } | ||||
return true; | |||||
} | |||||
DBErrors CWallet::LoadWallet(bool &fFirstRunRet) { | DBErrors CWallet::LoadWallet(bool &fFirstRunRet) { | ||||
// Even if we don't use this lock in this function, we want to preserve | // Even if we don't use this lock in this function, we want to preserve | ||||
// lock order in LoadToWallet if query of chain state is needed to know | // lock order in LoadToWallet if query of chain state is needed to know | ||||
// tx status. If lock can't be taken (e.g wallet-tool), tx confirmation | // tx status. If lock can't be taken (e.g wallet-tool), tx confirmation | ||||
// status may be not reliable. | // status may be not reliable. | ||||
auto locked_chain = LockChain(); | auto locked_chain = LockChain(); | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
▲ Show 20 Lines • Show All 1,743 Lines • Show Last 20 Lines |