Page MenuHomePhabricator

D7113.diff
No OneTemporary

D7113.diff

diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -157,9 +157,8 @@
std::string &fail_reason) = 0;
//! Commit transaction.
- virtual bool commitTransaction(CTransactionRef tx, WalletValueMap value_map,
- WalletOrderForm order_form,
- std::string &reject_reason) = 0;
+ virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map,
+ WalletOrderForm order_form) = 0;
//! Return whether transaction can be abandoned.
virtual bool transactionCanBeAbandoned(const TxId &txid) = 0;
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -228,19 +228,13 @@
}
return tx;
}
- bool commitTransaction(CTransactionRef tx, WalletValueMap value_map,
- WalletOrderForm order_form,
- std::string &reject_reason) override {
+ void commitTransaction(CTransactionRef tx, WalletValueMap value_map,
+ WalletOrderForm order_form) override {
auto locked_chain = m_wallet->chain().lock();
LOCK(m_wallet->cs_wallet);
TxValidationState state;
- if (!m_wallet->CommitTransaction(std::move(tx),
- std::move(value_map),
- std::move(order_form), state)) {
- reject_reason = state.GetRejectReason();
- return false;
- }
- return true;
+ m_wallet->CommitTransaction(std::move(tx), std::move(value_map),
+ std::move(order_form), state);
}
bool transactionCanBeAbandoned(const TxId &txid) override {
return m_wallet->TransactionCanBeAbandoned(txid);
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -569,9 +569,7 @@
// This comment is specific to SendCoinsDialog usage of
// WalletModel::SendCoinsReturn.
- // WalletModel::TransactionCommitFailed is used only in
- // WalletModel::sendCoins() all others are used only in
- // WalletModel::prepareTransaction()
+ // All status values are used only in WalletModel::prepareTransaction()
switch (sendCoinsReturn.status) {
case WalletModel::InvalidAddress:
msgParams.first =
@@ -596,12 +594,6 @@
msgParams.first = tr("Transaction creation failed!");
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
- case WalletModel::TransactionCommitFailed:
- msgParams.first =
- tr("The transaction was rejected with the following reason: %1")
- .arg(sendCoinsReturn.reasonCommitFailed);
- msgParams.second = CClientUIInterface::MSG_ERROR;
- break;
case WalletModel::AbsurdFee:
msgParams.first =
tr("A fee higher than %1 is considered an absurdly high fee.")
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -146,7 +146,6 @@
DuplicateAddress,
// Error returned when wallet is still locked
TransactionCreationFailed,
- TransactionCommitFailed,
AbsurdFee,
PaymentRequestExpired
};
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -256,12 +256,7 @@
}
auto &newTx = transaction.getWtx();
- std::string rejectReason;
- if (!wallet().commitTransaction(newTx, {} /* mapValue */,
- std::move(vOrderForm), rejectReason)) {
- return SendCoinsReturn(TransactionCommitFailed,
- QString::fromStdString(rejectReason));
- }
+ wallet().commitTransaction(newTx, {} /* mapValue */, std::move(vOrderForm));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << *newTx;
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -375,13 +375,8 @@
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}
TxValidationState 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 */,
+ state);
return tx;
}
@@ -1064,13 +1059,8 @@
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
}
TxValidationState 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 */,
+ state);
return tx->GetId().GetHex();
}
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -487,7 +487,7 @@
*locked_chain, {recipient}, tx, fee, changePos, error, dummy));
}
TxValidationState state;
- BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, state));
+ wallet->CommitTransaction(tx, {}, {}, state);
CMutableTransaction blocktx;
{
LOCK(wallet->cs_wallet);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -1352,7 +1352,7 @@
* @param state[in,out] TxValidationState object returning information about
* whether the transaction was accepted
*/
- bool CommitTransaction(
+ void CommitTransaction(
CTransactionRef tx, mapValue_t mapValue,
std::vector<std::pair<std::string, std::string>> orderForm,
TxValidationState &state);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3664,7 +3664,7 @@
return true;
}
-bool CWallet::CommitTransaction(
+void CWallet::CommitTransaction(
CTransactionRef tx, mapValue_t mapValue,
std::vector<std::pair<std::string, std::string>> orderForm,
TxValidationState &state) {
@@ -3695,18 +3695,19 @@
// fInMempool flag is cached properly
CWalletTx &wtx = mapWallet.at(wtxNew.GetId());
- if (fBroadcastTransactions) {
- std::string err_string;
- if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) {
- 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.
- }
+ if (!fBroadcastTransactions) {
+ // Don't submit tx to the mempool
+ return;
}
- return true;
+ std::string err_string;
+ if (!wtx.SubmitMemoryPoolAndRelay(err_string, true, *locked_chain)) {
+ 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.
+ }
}
DBErrors CWallet::LoadWallet(bool &fFirstRunRet) {

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:18 (8 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5185700
Default Alt Text
D7113.diff (8 KB)

Event Timeline