aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp1
-rw-r--r--src/daemon/command_parser_executor.cpp1
-rw-r--r--src/device_trezor/device_trezor.cpp2
-rw-r--r--src/device_trezor/device_trezor_base.cpp1
-rw-r--r--src/device_trezor/trezor/transport.cpp1
-rw-r--r--src/net/i2p_address.cpp2
-rw-r--r--src/net/parse.cpp1
-rw-r--r--src/net/socks_connect.cpp1
-rw-r--r--src/net/tor_address.cpp2
-rw-r--r--src/simplewallet/simplewallet.cpp7
-rw-r--r--src/wallet/api/wallet.cpp4
-rw-r--r--src/wallet/wallet2.cpp9
-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
15 files changed, 41 insertions, 10 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index 3e4532d4e..b0c4a25d8 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -32,6 +32,7 @@
#include <boost/algorithm/string.hpp>
#include "wipeable_string.h"
#include "string_tools.h"
+#include "string_tools_lexical.h"
#include "serialization/string.h"
#include "cryptonote_format_utils.h"
#include "cryptonote_config.h"
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index abca614cc..14233bf29 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -31,6 +31,7 @@
#include "net/parse.h"
#include "daemon/command_parser_executor.h"
#include <boost/filesystem.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "daemon"
diff --git a/src/device_trezor/device_trezor.cpp b/src/device_trezor/device_trezor.cpp
index 7c3e8785d..c2070b0d1 100644
--- a/src/device_trezor/device_trezor.cpp
+++ b/src/device_trezor/device_trezor.cpp
@@ -28,6 +28,8 @@
//
#include "device_trezor.hpp"
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string/predicate.hpp>
namespace hw {
namespace trezor {
diff --git a/src/device_trezor/device_trezor_base.cpp b/src/device_trezor/device_trezor_base.cpp
index 70dc7f539..5f21ecd49 100644
--- a/src/device_trezor/device_trezor_base.cpp
+++ b/src/device_trezor/device_trezor_base.cpp
@@ -31,6 +31,7 @@
#include "memwipe.h"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#include <boost/regex.hpp>
namespace hw {
diff --git a/src/device_trezor/trezor/transport.cpp b/src/device_trezor/trezor/transport.cpp
index a56090de0..be95868d0 100644
--- a/src/device_trezor/trezor/transport.cpp
+++ b/src/device_trezor/trezor/transport.cpp
@@ -38,6 +38,7 @@
#include <boost/asio/ip/udp.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/format.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#include "common/apply_permutation.h"
#include "transport.hpp"
#include "messages/messages-common.pb.h"
diff --git a/src/net/i2p_address.cpp b/src/net/i2p_address.cpp
index 6c03b3808..ada4eb0d3 100644
--- a/src/net/i2p_address.cpp
+++ b/src/net/i2p_address.cpp
@@ -38,7 +38,7 @@
#include "net/error.h"
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
-#include "string_tools.h"
+#include "string_tools_lexical.h"
namespace net
{
diff --git a/src/net/parse.cpp b/src/net/parse.cpp
index 8a98e941a..298576ba4 100644
--- a/src/net/parse.cpp
+++ b/src/net/parse.cpp
@@ -31,6 +31,7 @@
#include "net/tor_address.h"
#include "net/i2p_address.h"
#include "string_tools.h"
+#include "string_tools_lexical.h"
namespace net
{
diff --git a/src/net/socks_connect.cpp b/src/net/socks_connect.cpp
index 9db9d4483..c797a24d4 100644
--- a/src/net/socks_connect.cpp
+++ b/src/net/socks_connect.cpp
@@ -38,6 +38,7 @@
#include "net/net_utils_base.h"
#include "net/socks.h"
#include "string_tools.h"
+#include "string_tools_lexical.h"
namespace net
{
diff --git a/src/net/tor_address.cpp b/src/net/tor_address.cpp
index 4414861e7..a04dcb042 100644
--- a/src/net/tor_address.cpp
+++ b/src/net/tor_address.cpp
@@ -38,7 +38,7 @@
#include "net/error.h"
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
-#include "string_tools.h"
+#include "string_tools_lexical.h"
namespace net
{
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 0af896c76..c3325c24d 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -37,6 +37,7 @@
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/preprocessor/stringize.hpp>
@@ -8760,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);
@@ -8919,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);
@@ -9892,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