This commit is contained in:
Luke Parker
2023-03-11 05:23:38 -05:00
parent 4335baa43f
commit 71dbc798b5

View File

@@ -308,13 +308,13 @@ impl SignableTransaction {
// Include a random payment ID if we don't actually have one // Include a random payment ID if we don't actually have one
// It prevents transactions from leaking if they're sending to integrated addresses or not // It prevents transactions from leaking if they're sending to integrated addresses or not
let id = if let Some(id) = id { // Only do this if we only have two outputs though, as Monero won't add a dummy if there's
id // more than two outputs
} else { if outputs.len() <= 2 {
let mut id = [0; 8]; let mut rand = [0; 8];
rng.fill_bytes(&mut id); rng.fill_bytes(&mut rand);
id id = id.or(Some(rand));
}; }
let commitments = outputs.iter().map(|output| output.commitment.clone()).collect::<Vec<_>>(); let commitments = outputs.iter().map(|output| output.commitment.clone()).collect::<Vec<_>>();
let sum = commitments.iter().map(|commitment| commitment.mask).sum(); let sum = commitments.iter().map(|commitment| commitment.mask).sum();
@@ -329,9 +329,11 @@ impl SignableTransaction {
if additional { outputs.iter().map(|output| output.R).collect() } else { vec![] }, if additional { outputs.iter().map(|output| output.R).collect() } else { vec![] },
); );
let mut id_vec = Vec::with_capacity(1 + 8); if let Some(id) = id {
PaymentId::Encrypted(id).write(&mut id_vec).unwrap(); let mut id_vec = Vec::with_capacity(1 + 8);
extra.push(ExtraField::Nonce(id_vec)); PaymentId::Encrypted(id).write(&mut id_vec).unwrap();
extra.push(ExtraField::Nonce(id_vec));
}
// Include data if present // Include data if present
for part in self.data.drain(..) { for part in self.data.drain(..) {