diff --git a/Cargo.lock b/Cargo.lock index b3419a85..01edbcfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8123,7 +8123,6 @@ dependencies = [ name = "serai-bitcoin-processor" version = "0.1.0" dependencies = [ - "async-trait", "bitcoin-serai", "borsh", "ciphersuite", @@ -8349,7 +8348,6 @@ version = "0.1.0" name = "serai-ethereum-processor" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "const-hex", "env_logger", @@ -8514,7 +8512,6 @@ dependencies = [ name = "serai-monero-processor" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "ciphersuite", "dalek-ff-group", @@ -8644,7 +8641,6 @@ dependencies = [ name = "serai-processor-bin" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "ciphersuite", "dkg", @@ -8718,7 +8714,6 @@ dependencies = [ name = "serai-processor-primitives" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "group", "log", @@ -8732,7 +8727,6 @@ dependencies = [ name = "serai-processor-scanner" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "group", "hex", @@ -8762,7 +8756,6 @@ dependencies = [ name = "serai-processor-signers" version = "0.1.0" dependencies = [ - "async-trait", "borsh", "ciphersuite", "frost-schnorrkel", diff --git a/processor/monero/src/primitives/block.rs b/processor/monero/src/primitives/block.rs index ad28b0c1..634a0fbb 100644 --- a/processor/monero/src/primitives/block.rs +++ b/processor/monero/src/primitives/block.rs @@ -2,13 +2,13 @@ use std::collections::HashMap; use ciphersuite::{Ciphersuite, Ed25519}; -use monero_wallet::{transaction::Transaction, block::Block as MBlock}; +use monero_wallet::{transaction::Transaction, block::Block as MBlock, ViewPairError, GuaranteedViewPair, GuaranteedScanner}; use serai_client::networks::monero::Address; use primitives::{ReceivedOutput, EventualityTracker}; -use crate::{output::Output, transaction::Eventuality}; +use crate::{EXTERNAL_SUBADDRESS, BRANCH_SUBADDRESS, CHANGE_SUBADDRESS, FORWARDED_SUBADDRESS, output::Output, transaction::Eventuality}; #[derive(Clone, Debug)] pub(crate) struct BlockHeader(pub(crate) MBlock); @@ -37,6 +37,15 @@ impl primitives::Block for Block { } fn scan_for_outputs_unordered(&self, key: Self::Key) -> Vec { + let view_pair = match GuaranteedViewPair::new(key.0, additional_key) { + Ok(view_pair) => view_pair, + Err(ViewPairError::TorsionedSpendKey) => unreachable!("dalek_ff_group::EdwardsPoint has torsion"), + }; + let mut scanner = GuaranteedScanner::new(view_pair); + scanner.register_subaddress(EXTERNAL_SUBADDRESS.unwrap()); + scanner.register_subaddress(BRANCH_SUBADDRESS.unwrap()); + scanner.register_subaddress(CHANGE_SUBADDRESS.unwrap()); + scanner.register_subaddress(FORWARDED_SUBADDRESS.unwrap()); todo!("TODO") } diff --git a/processor/monero/src/primitives/mod.rs b/processor/monero/src/primitives/mod.rs index fba52dd9..de057399 100644 --- a/processor/monero/src/primitives/mod.rs +++ b/processor/monero/src/primitives/mod.rs @@ -1,3 +1,10 @@ +use monero_wallet::address::SubaddressIndex; + pub(crate) mod output; pub(crate) mod transaction; pub(crate) mod block; + +pub(crate) const EXTERNAL_SUBADDRESS: Option = SubaddressIndex::new(1, 0); +pub(crate) const BRANCH_SUBADDRESS: Option = SubaddressIndex::new(2, 0); +pub(crate) const CHANGE_SUBADDRESS: Option = SubaddressIndex::new(2, 1); +pub(crate) const FORWARDED_SUBADDRESS: Option = SubaddressIndex::new(2, 2); diff --git a/processor/monero/src/primitives/output.rs b/processor/monero/src/primitives/output.rs index d3eb3be3..385429c2 100644 --- a/processor/monero/src/primitives/output.rs +++ b/processor/monero/src/primitives/output.rs @@ -14,6 +14,8 @@ use serai_client::{ use primitives::{OutputType, ReceivedOutput}; +use crate::{EXTERNAL_SUBADDRESS, BRANCH_SUBADDRESS, CHANGE_SUBADDRESS, FORWARDED_SUBADDRESS}; + #[rustfmt::skip] #[derive( Clone, Copy, PartialEq, Eq, Default, Hash, Debug, Encode, Decode, BorshSerialize, BorshDeserialize, @@ -44,7 +46,19 @@ impl ReceivedOutput<::G, Address> for Output { type TransactionId = [u8; 32]; fn kind(&self) -> OutputType { - todo!("TODO") + if self.0.subaddress() == EXTERNAL_SUBADDRESS { + return OutputType::External; + } + if self.0.subaddress() == BRANCH_SUBADDRESS { + return OutputType::Branch; + } + if self.0.subaddress() == CHANGE_SUBADDRESS { + return OutputType::Change; + } + if self.0.subaddress() == FORWARDED_SUBADDRESS { + return OutputType::Forwarded; + } + unreachable!("scanned output to unknown subaddress"); } fn id(&self) -> Self::Id {