Fix Monero's Extra::fee_weight and handling of data limits

This commit is contained in:
Luke Parker
2023-03-26 03:43:51 -04:00
parent c182b804bc
commit 534e1bb11d
3 changed files with 20 additions and 11 deletions

View File

@@ -337,7 +337,8 @@ impl SignableTransaction {
has_payment_id |= outputs == 2;
// Calculate the extra length
let extra = Extra::fee_weight(outputs, has_payment_id, data.as_ref());
// Assume additional keys are needed in order to cause a worst-case estimation
let extra = Extra::fee_weight(outputs, true, has_payment_id, data.as_ref());
// https://github.com/monero-project/monero/pull/8733
const MAX_EXTRA_SIZE: usize = 1060;
@@ -541,7 +542,7 @@ impl SignableTransaction {
}
// Include data if present
let extra_len = Extra::fee_weight(Rs_len, id.is_some(), data.as_ref());
let extra_len = Extra::fee_weight(Rs_len, additional, id.is_some(), data.as_ref());
for part in data.drain(..) {
let mut arb = vec![ARBITRARY_DATA_MARKER];
arb.extend(part);