Correct Monero's extra length calculation for fee calculation

This commit is contained in:
Luke Parker 2022-06-19 12:19:57 -04:00
parent b6ea654823
commit 9d817a00b2
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6

View file

@ -220,8 +220,11 @@ impl SignableTransaction {
}
let mut outputs = payments.len() + (if change { 1 } else { 0 });
// Calculate the extra length.
// Type, length, value, with 1 field for the first key and 1 field for the rest
let extra = (outputs * (2 + 32)) - (outputs.saturating_sub(2) * 2);
// Calculate the fee.
let extra = 0;
let mut fee = fee_rate.calculate(Transaction::fee_weight(inputs.len(), outputs, extra));
// Make sure we have enough funds