Fixes #1299 - Fails to send transaction when not enough funds for fee (#1311)

This commit is contained in:
Quentin Le Sceller 2018-08-02 12:05:38 -04:00 committed by Ignotus Peverell
parent a638bd7499
commit 3ee01055ed

View file

@ -258,8 +258,16 @@ where
})?; })?;
} }
// Check if we need to use a change address // The amount with fee is more than the total values of our max outputs
if total > amount_with_fee { if total < amount_with_fee && coins.len() == max_outputs {
return Err(ErrorKind::NotEnoughFunds {
available: total,
needed: amount_with_fee as u64,
})?;
}
// We need to add a change address or amount with fee is more than total
if total != amount_with_fee {
fee = tx_fee(coins.len(), 2, None); fee = tx_fee(coins.len(), 2, None);
amount_with_fee = amount + fee; amount_with_fee = amount + fee;