mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 08:17:37 +00:00
Merge pull request #7651
c8ff1d4
monero-wallet-cli: improve error message when tx amount is zero (Elliot Wirrick)
This commit is contained in:
commit
9bba3f4767
6 changed files with 30 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue