[bug] correctly handle the case available funds are equal or just above target
This commit is contained in:
parent
326eb56b62
commit
8f1b4a9071
@ -57,15 +57,17 @@ pub fn create_transaction(
|
||||
inputs.insert(must_outpoint, must_output);
|
||||
}
|
||||
|
||||
let fee_provision = sum_outputs.checked_div(10).unwrap();
|
||||
|
||||
for (outpoint, output) in available_outpoints {
|
||||
if total_available > sum_outputs.checked_add(sum_outputs.checked_div(10).unwrap()).unwrap() {
|
||||
if total_available > sum_outputs.checked_add(fee_provision).unwrap() {
|
||||
break;
|
||||
}
|
||||
total_available += output.amount;
|
||||
inputs.insert(outpoint, output);
|
||||
}
|
||||
|
||||
if total_available < sum_outputs {
|
||||
if total_available <= sum_outputs.checked_add(fee_provision).unwrap() {
|
||||
return Err(Error::msg("Not enough available funds"));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user