mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-11 05:14:41 +00:00
Support sending to subaddresses
This commit is contained in:
parent
1ef528bf8c
commit
b91279f4ce
1 changed files with 9 additions and 6 deletions
|
@ -11,7 +11,7 @@ use curve25519_dalek::{
|
||||||
|
|
||||||
use monero::{
|
use monero::{
|
||||||
consensus::Encodable,
|
consensus::Encodable,
|
||||||
util::{key::PublicKey, address::Address},
|
util::{key::PublicKey, address::{AddressType, Address}},
|
||||||
blockdata::transaction::SubField
|
blockdata::transaction::SubField
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,13 +61,15 @@ impl SendOutput {
|
||||||
o
|
o
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let spend = output.0.public_spend.point.decompress().ok_or(TransactionError::InvalidAddress)?;
|
||||||
Ok(
|
Ok(
|
||||||
SendOutput {
|
SendOutput {
|
||||||
R: &r * &ED25519_BASEPOINT_TABLE,
|
R: match output.0.addr_type {
|
||||||
dest: (
|
AddressType::Standard => Ok(&r * &ED25519_BASEPOINT_TABLE),
|
||||||
(&shared_key * &ED25519_BASEPOINT_TABLE) +
|
AddressType::SubAddress => Ok(&r * spend),
|
||||||
output.0.public_spend.point.decompress().ok_or(TransactionError::InvalidAddress)?
|
AddressType::Integrated(_) => Err(TransactionError::InvalidAddress)
|
||||||
),
|
}?,
|
||||||
|
dest: (&shared_key * &ED25519_BASEPOINT_TABLE) + spend,
|
||||||
mask: commitment_mask(shared_key),
|
mask: commitment_mask(shared_key),
|
||||||
amount: amount_encryption(output.1, shared_key)
|
amount: amount_encryption(output.1, shared_key)
|
||||||
}
|
}
|
||||||
|
@ -233,6 +235,7 @@ impl SignableTransaction {
|
||||||
bp: Bulletproofs
|
bp: Bulletproofs
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
// Create the TX extra
|
// Create the TX extra
|
||||||
|
// TODO: Review this for canonicity with Monero
|
||||||
let mut extra = vec![];
|
let mut extra = vec![];
|
||||||
SubField::TxPublicKey(
|
SubField::TxPublicKey(
|
||||||
PublicKey { point: self.outputs[0].R.compress() }
|
PublicKey { point: self.outputs[0].R.compress() }
|
||||||
|
|
Loading…
Reference in a new issue