From cf709a6b8938cc87951577aa7889bfac033ce94d Mon Sep 17 00:00:00 2001 From: j-berman Date: Tue, 9 Jan 2024 07:27:44 -0800 Subject: [PATCH] monero: scan all tx pub keys (not additional) for every tx wallet2's behavior is explained more fully here: https://github.com/UkoeHB/monero/issues/27 --- coins/monero/src/wallet/extra.rs | 12 ++++++++---- coins/monero/src/wallet/scan.rs | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/coins/monero/src/wallet/extra.rs b/coins/monero/src/wallet/extra.rs index 93cac861d..5f544a7f7 100644 --- a/coins/monero/src/wallet/extra.rs +++ b/coins/monero/src/wallet/extra.rs @@ -120,12 +120,12 @@ impl ExtraField { #[derive(Clone, PartialEq, Eq, Debug, Zeroize)] pub struct Extra(Vec); impl Extra { - pub fn keys(&self) -> Option<(EdwardsPoint, Option>)> { - let mut key = None; + pub fn keys(&self) -> Option<(Vec, Option>)> { + let mut keys = vec![]; let mut additional = None; for field in &self.0 { match field.clone() { - ExtraField::PublicKey(this_key) => key = key.or(Some(this_key)), + ExtraField::PublicKey(this_key) => keys.push(this_key), ExtraField::PublicKeys(these_additional) => { additional = additional.or(Some(these_additional)) } @@ -133,7 +133,11 @@ impl Extra { } } // Don't return any keys if this was non-standard and didn't include the primary key - key.map(|key| (key, additional)) + if keys.is_empty() { + None + } else { + Some((keys, additional)) + } } pub fn payment_id(&self) -> Option { diff --git a/coins/monero/src/wallet/scan.rs b/coins/monero/src/wallet/scan.rs index df73cb8a2..3273827f2 100644 --- a/coins/monero/src/wallet/scan.rs +++ b/coins/monero/src/wallet/scan.rs @@ -334,7 +334,7 @@ impl Scanner { return Timelocked(tx.prefix.timelock, vec![]); }; - let Some((tx_key, additional)) = extra.keys() else { + let Some((tx_keys, additional)) = extra.keys() else { return Timelocked(tx.prefix.timelock, vec![]); }; @@ -355,7 +355,9 @@ impl Scanner { } let output_key = output_key.unwrap(); - for key in [Some(Some(&tx_key)), additional.as_ref().map(|additional| additional.get(o))] { + let additional = additional.as_ref().map(|additional| additional.get(o)); + + for key in tx_keys.iter().map(|key| Some(Some(key))).chain(core::iter::once(additional)) { let key = match key { Some(Some(key)) => key, Some(None) => {