mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-11 05:14:41 +00:00
Define subaddress indexes to use
(1, 0) is the external address. (2, *) are the internal addresses.
This commit is contained in:
parent
e78236276a
commit
1b39138472
4 changed files with 33 additions and 10 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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<Self::Output> {
|
||||
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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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> = SubaddressIndex::new(1, 0);
|
||||
pub(crate) const BRANCH_SUBADDRESS: Option<SubaddressIndex> = SubaddressIndex::new(2, 0);
|
||||
pub(crate) const CHANGE_SUBADDRESS: Option<SubaddressIndex> = SubaddressIndex::new(2, 1);
|
||||
pub(crate) const FORWARDED_SUBADDRESS: Option<SubaddressIndex> = SubaddressIndex::new(2, 2);
|
||||
|
|
|
@ -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<<Ed25519 as Ciphersuite>::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 {
|
||||
|
|
Loading…
Reference in a new issue