Support sending to subaddresses

This commit is contained in:
Luke Parker 2022-06-10 02:38:19 -04:00
parent 1ef528bf8c
commit b91279f4ce
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6

View file

@ -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() }