Define subaddress indexes to use

(1, 0) is the external address. (2, *) are the internal addresses.
This commit is contained in:
Luke Parker
2024-09-13 02:12:32 -04:00
parent e78236276a
commit 1b39138472
4 changed files with 33 additions and 10 deletions

View File

@@ -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 {