From 9d817a00b2216158c2fda1bcdcacd9fa1e7939a7 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 19 Jun 2022 12:19:57 -0400 Subject: [PATCH] Correct Monero's extra length calculation for fee calculation --- coins/monero/src/wallet/send/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coins/monero/src/wallet/send/mod.rs b/coins/monero/src/wallet/send/mod.rs index a9a689dd..7c95d753 100644 --- a/coins/monero/src/wallet/send/mod.rs +++ b/coins/monero/src/wallet/send/mod.rs @@ -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