aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/simplewallet/simplewallet.cpp7
-rw-r--r--src/wallet/api/wallet.cpp4
-rw-r--r--src/wallet/wallet2.cpp8
-rw-r--r--src/wallet/wallet_errors.h11
-rw-r--r--src/wallet/wallet_rpc_server.cpp7
-rw-r--r--src/wallet/wallet_rpc_server_error_codes.h1
6 files changed, 30 insertions, 8 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index da6501183..a7856d60f 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -608,9 +608,14 @@ void simple_wallet::handle_transfer_exception(const std::exception_ptr &e, bool
fail_msg_writer() << e.what();
warn_of_possible_attack = false;
}
+ catch (const tools::error::zero_amount&)
+ {
+ fail_msg_writer() << sw::tr("destination amount is zero");
+ warn_of_possible_attack = false;
+ }
catch (const tools::error::zero_destination&)
{
- fail_msg_writer() << sw::tr("one of destinations is zero");
+ fail_msg_writer() << sw::tr("transaction has no destination");
warn_of_possible_attack = false;
}
catch (const tools::error::tx_too_big& e)
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 5d9eb7a14..adff042ad 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -1565,8 +1565,10 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
setStatusError(writer.str());
} catch (const tools::error::tx_sum_overflow& e) {
setStatusError(e.what());
+ } catch (const tools::error::zero_amount&) {
+ setStatusError(tr("destination amount is zero"));
} catch (const tools::error::zero_destination&) {
- setStatusError(tr("one of destinations is zero"));
+ setStatusError(tr("transaction has no destination"));
} catch (const tools::error::tx_too_big& e) {
setStatusError(tr("failed to find a suitable way to split transactions"));
} catch (const tools::error::transfer_error& e) {
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 56f0ef11c..c3325c24d 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -8761,7 +8761,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
// throw if total amount overflows uint64_t
for(auto& dt: dsts)
{
- THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_destination);
+ THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_amount);
needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, fee, m_nettype);
@@ -8920,7 +8920,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
// throw if total amount overflows uint64_t
for(auto& dt: dsts)
{
- THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_destination);
+ THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_amount);
needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, fee, m_nettype);
@@ -9893,14 +9893,14 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
needed_money = 0;
for(auto& dt: dsts)
{
- THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_destination);
+ THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_amount);
needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, 0, m_nettype);
}
// throw if attempting a transaction with no money
- THROW_WALLET_EXCEPTION_IF(needed_money == 0, error::zero_destination);
+ THROW_WALLET_EXCEPTION_IF(needed_money == 0, error::zero_amount);
std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddr = unlocked_balance_per_subaddress(subaddr_account, false);
std::map<uint32_t, uint64_t> balance_per_subaddr = balance_per_subaddress(subaddr_account, false);
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index 4a89ed81a..011780f43 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -83,6 +83,7 @@ namespace tools
// tx_rejected
// tx_sum_overflow
// tx_too_big
+ // zero_amount
// zero_destination
// wallet_rpc_error *
// daemon_busy
@@ -750,10 +751,18 @@ namespace tools
uint64_t m_tx_weight_limit;
};
//----------------------------------------------------------------------------------------------------
+ struct zero_amount: public transfer_error
+ {
+ explicit zero_amount(std::string&& loc)
+ : transfer_error(std::move(loc), "destination amount is zero")
+ {
+ }
+ };
+ //----------------------------------------------------------------------------------------------------
struct zero_destination : public transfer_error
{
explicit zero_destination(std::string&& loc)
- : transfer_error(std::move(loc), "destination amount is zero")
+ : transfer_error(std::move(loc), "transaction has no destination")
{
}
};
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index b39a40b64..0b200ae60 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -822,7 +822,7 @@ namespace tools
if (at_least_one_destination && dsts.empty())
{
er.code = WALLET_RPC_ERROR_CODE_ZERO_DESTINATION;
- er.message = "No destinations for this transfer";
+ er.message = "Transaction has no destination";
return false;
}
@@ -3359,6 +3359,11 @@ namespace tools
er.code = WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY;
er.message = e.what();
}
+ catch (const tools::error::zero_amount& e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_ZERO_AMOUNT;
+ er.message = e.what();
+ }
catch (const tools::error::zero_destination& e)
{
er.code = WALLET_RPC_ERROR_CODE_ZERO_DESTINATION;
diff --git a/src/wallet/wallet_rpc_server_error_codes.h b/src/wallet/wallet_rpc_server_error_codes.h
index f7c5bb0e1..b991029a9 100644
--- a/src/wallet/wallet_rpc_server_error_codes.h
+++ b/src/wallet/wallet_rpc_server_error_codes.h
@@ -76,4 +76,5 @@
#define WALLET_RPC_ERROR_CODE_NON_DETERMINISTIC -43
#define WALLET_RPC_ERROR_CODE_INVALID_LOG_LEVEL -44
#define WALLET_RPC_ERROR_CODE_ATTRIBUTE_NOT_FOUND -45
+#define WALLET_RPC_ERROR_CODE_ZERO_AMOUNT -46
#define WALLET_RPC_ERROR_CODE_INVALID_SIGNATURE_TYPE -47