0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

[wallet] Fix whitespace in CWallet::CommitTransaction()

Reviewer hint: use --ignore-all-space git diff option for review.
This commit is contained in:
John Newbery 2019-04-03 17:29:21 -04:00
parent c34b88620d
commit 8bba91b22d

View file

@ -3291,45 +3291,40 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
*/ */
bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CValidationState& state) bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CValidationState& 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);
wtxNew.vOrderForm = std::move(orderForm); wtxNew.vOrderForm = std::move(orderForm);
wtxNew.fTimeReceivedIsTxTime = true; wtxNew.fTimeReceivedIsTxTime = true;
wtxNew.fFromMe = true; wtxNew.fFromMe = true;
WalletLogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString()); /* Continued */ WalletLogPrintf("CommitTransaction:\n%s", wtxNew.tx->ToString()); /* Continued */
{
// Add tx to wallet, because if it has change it's also ours, // Add tx to wallet, because if it has change it's also ours,
// otherwise just for transaction history. // otherwise just for transaction history.
AddToWallet(wtxNew); AddToWallet(wtxNew);
// Notify that old coins are spent // Notify that old coins are spent
for (const CTxIn& txin : wtxNew.tx->vin) for (const CTxIn& txin : wtxNew.tx->vin) {
{ CWalletTx &coin = mapWallet.at(txin.prevout.hash);
CWalletTx &coin = mapWallet.at(txin.prevout.hash); coin.BindWallet(this);
coin.BindWallet(this); NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
NotifyTransactionChanged(this, coin.GetHash(), 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.GetHash()); CWalletTx& wtx = mapWallet.at(wtxNew.GetHash());
if (fBroadcastTransactions) if (fBroadcastTransactions) {
{ 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 broadcast immediately, %s\n", err_string);
WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", err_string); // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
}
} }
} }
return true; return true;
} }