mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Include subaddress and payment ID in SpendableOutput
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use core::ops::BitXor;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use zeroize::Zeroize;
|
||||
@@ -15,6 +16,19 @@ pub(crate) enum PaymentId {
|
||||
Encrypted([u8; 8]),
|
||||
}
|
||||
|
||||
impl BitXor<[u8; 8]> for PaymentId {
|
||||
type Output = PaymentId;
|
||||
|
||||
fn bitxor(self, bytes: [u8; 8]) -> PaymentId {
|
||||
match self {
|
||||
PaymentId::Unencrypted(_) => self,
|
||||
PaymentId::Encrypted(id) => {
|
||||
PaymentId::Encrypted((u64::from_le_bytes(id) ^ u64::from_le_bytes(bytes)).to_le_bytes())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PaymentId {
|
||||
fn serialize<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
match self {
|
||||
@@ -115,6 +129,15 @@ impl Extra {
|
||||
keys
|
||||
}
|
||||
|
||||
pub(crate) fn payment_id(&self) -> Option<PaymentId> {
|
||||
for field in &self.0 {
|
||||
if let ExtraField::PaymentId(id) = field {
|
||||
return Some(*id);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn data(&self) -> Option<Vec<u8>> {
|
||||
for field in &self.0 {
|
||||
if let ExtraField::Padding(data) = field {
|
||||
|
||||
Reference in New Issue
Block a user