@@ -3291,45 +3291,40 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
3291
3291
*/
3292
3292
bool CWallet::CommitTransaction (CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CValidationState& state)
3293
3293
{
3294
- {
3295
- auto locked_chain = chain ().lock ();
3296
- LOCK (cs_wallet);
3294
+ auto locked_chain = chain ().lock ();
3295
+ LOCK (cs_wallet);
3297
3296
3298
- CWalletTx wtxNew (this , std::move (tx));
3299
- wtxNew.mapValue = std::move (mapValue);
3300
- wtxNew.vOrderForm = std::move (orderForm);
3301
- wtxNew.fTimeReceivedIsTxTime = true ;
3302
- wtxNew.fFromMe = true ;
3297
+ CWalletTx wtxNew (this , std::move (tx));
3298
+ wtxNew.mapValue = std::move (mapValue);
3299
+ wtxNew.vOrderForm = std::move (orderForm);
3300
+ wtxNew.fTimeReceivedIsTxTime = true ;
3301
+ wtxNew.fFromMe = true ;
3303
3302
3304
- WalletLogPrintf (" CommitTransaction:\n %s" , wtxNew.tx ->ToString ()); /* Continued */
3305
- {
3303
+ WalletLogPrintf (" CommitTransaction:\n %s" , wtxNew.tx ->ToString ()); /* Continued */
3306
3304
3307
- // Add tx to wallet, because if it has change it's also ours,
3308
- // otherwise just for transaction history.
3309
- AddToWallet (wtxNew);
3305
+ // Add tx to wallet, because if it has change it's also ours,
3306
+ // otherwise just for transaction history.
3307
+ AddToWallet (wtxNew);
3310
3308
3311
- // Notify that old coins are spent
3312
- for (const CTxIn& txin : wtxNew.tx ->vin )
3313
- {
3314
- CWalletTx &coin = mapWallet.at (txin.prevout .hash );
3315
- coin.BindWallet (this );
3316
- NotifyTransactionChanged (this , coin.GetHash (), CT_UPDATED);
3317
- }
3318
- }
3309
+ // Notify that old coins are spent
3310
+ for (const CTxIn& txin : wtxNew.tx ->vin ) {
3311
+ CWalletTx &coin = mapWallet.at (txin.prevout .hash );
3312
+ coin.BindWallet (this );
3313
+ NotifyTransactionChanged (this , coin.GetHash (), CT_UPDATED);
3314
+ }
3319
3315
3320
- // Get the inserted-CWalletTx from mapWallet so that the
3321
- // fInMempool flag is cached properly
3322
- CWalletTx& wtx = mapWallet.at (wtxNew.GetHash ());
3316
+ // Get the inserted-CWalletTx from mapWallet so that the
3317
+ // fInMempool flag is cached properly
3318
+ CWalletTx& wtx = mapWallet.at (wtxNew.GetHash ());
3323
3319
3324
- if (fBroadcastTransactions )
3325
- {
3326
- std::string err_string;
3327
- if (!wtx.SubmitMemoryPoolAndRelay (err_string, true , *locked_chain)) {
3328
- WalletLogPrintf (" CommitTransaction(): Transaction cannot be broadcast immediately, %s\n " , err_string);
3329
- // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
3330
- }
3320
+ if (fBroadcastTransactions ) {
3321
+ std::string err_string;
3322
+ if (!wtx.SubmitMemoryPoolAndRelay (err_string, true , *locked_chain)) {
3323
+ WalletLogPrintf (" CommitTransaction(): Transaction cannot be broadcast immediately, %s\n " , err_string);
3324
+ // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
3331
3325
}
3332
3326
}
3327
+
3333
3328
return true ;
3334
3329
}
3335
3330
0 commit comments