wallet2: consider minimum fee when testing if balance is sufficient
This commit is contained in:
parent
7d2d8055ac
commit
f2e65c6e50
|
@ -7675,6 +7675,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
// early out if we know we can't make it anyway
|
// 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
|
// 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
|
// ever changes, this might be missed, so let this go through
|
||||||
|
const uint64_t min_fee = (fee_multiplier * fee_per_kb * estimate_tx_size(use_rct, 1, fake_outs_count, 2, extra.size(), bulletproof)) / 1024;
|
||||||
uint64_t balance_subtotal = 0;
|
uint64_t balance_subtotal = 0;
|
||||||
uint64_t unlocked_balance_subtotal = 0;
|
uint64_t unlocked_balance_subtotal = 0;
|
||||||
for (uint32_t index_minor : subaddr_indices)
|
for (uint32_t index_minor : subaddr_indices)
|
||||||
|
@ -7682,10 +7683,10 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
balance_subtotal += balance_per_subaddr[index_minor];
|
balance_subtotal += balance_per_subaddr[index_minor];
|
||||||
unlocked_balance_subtotal += unlocked_balance_per_subaddr[index_minor];
|
unlocked_balance_subtotal += unlocked_balance_per_subaddr[index_minor];
|
||||||
}
|
}
|
||||||
THROW_WALLET_EXCEPTION_IF(needed_money > balance_subtotal, error::not_enough_money,
|
THROW_WALLET_EXCEPTION_IF(needed_money + min_fee > balance_subtotal, error::not_enough_money,
|
||||||
balance_subtotal, needed_money, 0);
|
balance_subtotal, needed_money, 0);
|
||||||
// first check overall balance is enough, then unlocked one, so we throw distinct exceptions
|
// first check overall balance is enough, then unlocked one, so we throw distinct exceptions
|
||||||
THROW_WALLET_EXCEPTION_IF(needed_money > unlocked_balance_subtotal, error::not_enough_unlocked_money,
|
THROW_WALLET_EXCEPTION_IF(needed_money + min_fee > unlocked_balance_subtotal, error::not_enough_unlocked_money,
|
||||||
unlocked_balance_subtotal, needed_money, 0);
|
unlocked_balance_subtotal, needed_money, 0);
|
||||||
|
|
||||||
for (uint32_t i : subaddr_indices)
|
for (uint32_t i : subaddr_indices)
|
||||||
|
|
Loading…
Reference in New Issue