diff options
author | binaryFate <binaryfate@users.noreply.github.com> | 2017-10-16 15:13:23 +0200 |
---|---|---|
committer | binaryFate <binaryfate@users.noreply.github.com> | 2017-10-16 15:14:09 +0200 |
commit | b2d416f211d548b46808988fb19520c0a570b5a8 (patch) | |
tree | 49b2a6df6dcca9094538ffbe6b5b7df5d16c7823 /src/wallet/wallet2.cpp | |
parent | Merge pull request #2601 (diff) | |
download | monero-b2d416f211d548b46808988fb19520c0a570b5a8.tar.xz |
Distinguish "not enough money" and "not enough unlocked money"
Fix #1530
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet2.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index cc0e9e7e2..61979ecf8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4441,7 +4441,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent } LOG_PRINT_L2("wanted " << print_money(needed_money) << ", found " << print_money(found_money) << ", fee " << print_money(fee)); - THROW_WALLET_EXCEPTION_IF(found_money < needed_money, error::not_enough_money, found_money, needed_money - fee, fee); + THROW_WALLET_EXCEPTION_IF(found_money < needed_money, error::not_enough_unlocked_money, found_money, needed_money - fee, fee); uint32_t subaddr_account = m_transfers[*selected_transfers.begin()].m_subaddr_index.major; for (auto i = ++selected_transfers.begin(); i != selected_transfers.end(); ++i) @@ -4598,7 +4598,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry } LOG_PRINT_L2("wanted " << print_money(needed_money) << ", found " << print_money(found_money) << ", fee " << print_money(fee)); - THROW_WALLET_EXCEPTION_IF(found_money < needed_money, error::not_enough_money, found_money, needed_money - fee, fee); + THROW_WALLET_EXCEPTION_IF(found_money < needed_money, error::not_enough_unlocked_money, found_money, needed_money - fee, fee); uint32_t subaddr_account = m_transfers[*selected_transfers.begin()].m_subaddr_index.major; for (auto i = ++selected_transfers.begin(); i != selected_transfers.end(); ++i) @@ -5475,6 +5475,15 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp } } + // 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 + // first check overall balance is enough, then unlocked one, so we throw distinct exceptions + THROW_WALLET_EXCEPTION_IF(needed_money > balance(), error::not_enough_money, + unlocked_balance(), needed_money, 0); + THROW_WALLET_EXCEPTION_IF(needed_money > unlocked_balance(), error::not_enough_unlocked_money, + unlocked_balance(), needed_money, 0); + // shuffle & sort output indices { std::random_device rd; |