Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,114 Lines • ▼ Show 20 Lines | CWallet::TransactionChangeType(const std::optional<OutputType> &change_type, | ||||
} | } | ||||
// else use m_default_address_type for change | // else use m_default_address_type for change | ||||
return m_default_address_type; | return m_default_address_type; | ||||
} | } | ||||
void 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, | ||||
bool broadcast) { | |||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
WalletLogPrintfToBeContinued("CommitTransaction:\n%s", tx->ToString()); | WalletLogPrintfToBeContinued("CommitTransaction:\n%s", tx->ToString()); | ||||
// Add tx to wallet, because if it has change it's also ours, otherwise just | // Add tx to wallet, because if it has change it's also ours, otherwise just | ||||
// for transaction history. | // for transaction history. | ||||
AddToWallet(tx, {}, [&](CWalletTx &wtx, bool new_tx) { | AddToWallet(tx, {}, [&](CWalletTx &wtx, bool new_tx) { | ||||
CHECK_NONFATAL(wtx.mapValue.empty()); | CHECK_NONFATAL(wtx.mapValue.empty()); | ||||
Show All 11 Lines | for (const CTxIn &txin : tx->vin) { | ||||
coin.MarkDirty(); | 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 (!broadcast || !fBroadcastTransactions) { | ||||
// Don't submit tx to the mempool | // Don't submit tx to the mempool if the flag is unset for this single | ||||
// transaction, or if the wallet doesn't broadcast transactions at all. | |||||
return; | return; | ||||
} | } | ||||
std::string err_string; | std::string err_string; | ||||
if (!SubmitTxMemoryPoolAndRelay(wtx, err_string, true)) { | if (!SubmitTxMemoryPoolAndRelay(wtx, err_string, true)) { | ||||
WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast " | WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast " | ||||
"immediately, %s\n", | "immediately, %s\n", | ||||
err_string); | err_string); | ||||
▲ Show 20 Lines • Show All 1,331 Lines • Show Last 20 Lines |