mirror of
https://github.com/monero-project/monero.git
synced 2026-08-02 17:08:25 -07:00
wallet: improve error messages when not enough money for transfer
This commit is contained in:
@@ -3457,6 +3457,12 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||
}
|
||||
LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs");
|
||||
|
||||
// early out if we know we can't make it anyway
|
||||
// we could also check for being within FEE_PER_KB, but if the fee calculation
|
||||
// ever changes, this might be missed, so let this go through
|
||||
THROW_WALLET_EXCEPTION_IF(needed_money > unlocked_balance(), error::not_enough_money,
|
||||
unlocked_balance(), needed_money, 0);
|
||||
|
||||
if (unused_dust_indices.empty() && unused_transfers_indices.empty())
|
||||
return std::vector<wallet2::pending_tx>();
|
||||
|
||||
@@ -3497,7 +3503,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||
// if we need to spend money and don't have any left, we fail
|
||||
if (unused_dust_indices.empty() && unused_transfers_indices.empty()) {
|
||||
LOG_PRINT_L2("No more outputs to choose from");
|
||||
THROW_WALLET_EXCEPTION_IF(1, error::not_enough_money, unlocked_balance(), needed_money, accumulated_fee + needed_fee);
|
||||
THROW_WALLET_EXCEPTION_IF(1, error::tx_not_possible, unlocked_balance(), needed_money, accumulated_fee + needed_fee);
|
||||
}
|
||||
|
||||
// get a random unspent output and use it to pay part (or all) of the current destination (and maybe next one, etc)
|
||||
@@ -3637,7 +3643,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||
if (adding_fee)
|
||||
{
|
||||
LOG_PRINT_L1("We ran out of outputs while trying to gather final fee");
|
||||
THROW_WALLET_EXCEPTION_IF(1, error::not_enough_money, unlocked_balance(), needed_money, accumulated_fee + needed_fee);
|
||||
THROW_WALLET_EXCEPTION_IF(1, error::tx_not_possible, unlocked_balance(), needed_money, accumulated_fee + needed_fee);
|
||||
}
|
||||
|
||||
LOG_PRINT_L1("Done creating " << txes.size() << " transactions, " << print_money(accumulated_fee) <<
|
||||
|
||||
Reference in New Issue
Block a user