mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #17154: wallet: Remove return value from CommitTransaction
9e95931865[wallet] Remove `state` argument from CWallet::CommitTransaction (John Newbery)d1734f9a3b[wallet] Remove return value from CommitTransaction() (John Newbery)b6f486a02b[wallet] Add doxygen comment to CWallet::CommitTransaction() (John Newbery)8bba91b22d[wallet] Fix whitespace in CWallet::CommitTransaction() (John Newbery) Pull request description: `CommitTransaction()` returns a bool to indicate success, but since commitb3a7410(#9302) it only returns true, even if the transaction was not successfully broadcast. This commit changes CommitTransaction() to return void. All dead code in `if (!CommitTransaction())` branches has been removed. Two additional commits fix up the idiosyncratic whitespace in `CommitTransaction` and add a doxygen comment for the function. ACKs for top commit: laanwj: ACK9e95931865Tree-SHA512: a55a2c20369a45222fc0e02d0891495655a926e71c4f52cb72624768dd7b9c1dca716ea67d38420afb90f40c6e0fd448caa60c18fd693bb10ecb110b641820e6
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <amount.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <core_io.h>
|
||||
#include <init.h>
|
||||
#include <interfaces/chain.h>
|
||||
@@ -341,11 +340,7 @@ static CTransactionRef SendMoney(interfaces::Chain::Lock& locked_chain, CWallet
|
||||
strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
}
|
||||
CValidationState state;
|
||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, state)) {
|
||||
strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
}
|
||||
pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */);
|
||||
return tx;
|
||||
}
|
||||
|
||||
@@ -926,12 +921,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
|
||||
bool fCreated = pwallet->CreateTransaction(*locked_chain, vecSend, tx, nFeeRequired, nChangePosRet, strFailReason, coin_control);
|
||||
if (!fCreated)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
|
||||
CValidationState state;
|
||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, state)) {
|
||||
strFailReason = strprintf("Transaction commit failed:: %s", FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
|
||||
}
|
||||
|
||||
pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */);
|
||||
return tx->GetHash().GetHex();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user