From 629de9fab487d50a05bfbe894976e02fca523deb Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Tue, 22 Jun 2021 11:38:18 +0200 Subject: [PATCH] Fix small issues related to #3020 --- .../core/src/transactions/aggregated_body.rs | 2 +- .../core/src/transactions/transaction.rs | 18 +++++++++--------- .../transaction_protocol/sender.rs | 3 +++ .../transaction_protocol/single_receiver.rs | 2 +- base_layer/wallet/src/wallet.rs | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/base_layer/core/src/transactions/aggregated_body.rs b/base_layer/core/src/transactions/aggregated_body.rs index 61007cbadfc..b60901667b3 100644 --- a/base_layer/core/src/transactions/aggregated_body.rs +++ b/base_layer/core/src/transactions/aggregated_body.rs @@ -416,7 +416,7 @@ impl AggregateBody { fn validate_sender_signatures(&self) -> Result<(), TransactionError> { trace!(target: LOG_TARGET, "Checking sender signatures"); for o in &self.outputs { - let _ = o.verify_sender_signature()?; + o.verify_sender_signature()?; } Ok(()) } diff --git a/base_layer/core/src/transactions/transaction.rs b/base_layer/core/src/transactions/transaction.rs index 003017531e4..3c8ef3b34a0 100644 --- a/base_layer/core/src/transactions/transaction.rs +++ b/base_layer/core/src/transactions/transaction.rs @@ -201,7 +201,7 @@ pub enum TransactionError { /// An unblinded output is one where the value and spending key (blinding factor) are known. This can be used to /// build both inputs and outputs (every input comes from an output) -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone)] pub struct UnblindedOutput { pub value: MicroTari, pub spending_key: BlindingFactor, @@ -374,7 +374,7 @@ pub struct TransactionInput { pub height: u64, /// A signature with k_s, signing the script, input data, and mined height pub script_signature: Signature, - /// The offset pubkey, K_O + /// The offset public key, K_O pub script_offset_public_key: PublicKey, } @@ -412,7 +412,7 @@ impl TransactionInput { } /// This will check if the input and the output is the same commitment by looking at the commitment and features. - /// This will ignore the output rangeproof + /// This will ignore the output range proof pub fn is_equal_to(&self, output: &TransactionOutput) -> bool { self.commitment == output.commitment && self.features == output.features } @@ -601,7 +601,7 @@ impl TransactionOutput { } /// This will check if the input and the output is the same commitment by looking at the commitment and features. - /// This will ignore the output rangeproof + /// This will ignore the output range proof #[inline] pub fn is_equal_to(&self, output: &TransactionInput) -> bool { self.commitment == output.commitment && self.features == output.features @@ -617,18 +617,18 @@ impl TransactionOutput { script: &TariScript, features: &OutputFeatures, script_offset_public_key: &PublicKey, - puplic_nonce: &PublicKey, + public_nonce: &PublicKey, ) -> MessageHash { Challenge::new() .chain(script.as_bytes()) .chain(features.to_bytes()) .chain(script_offset_public_key.as_bytes()) - .chain(puplic_nonce.as_bytes()) + .chain(public_nonce.as_bytes()) .result() .to_vec() } - /// Create sender signature fore the output meta data + /// Create sender signature for the output meta data pub fn create_sender_signature( script: &TariScript, output_features: &OutputFeatures, @@ -1011,7 +1011,7 @@ impl Transaction { .fold(0, |max_maturity, input| max(max_maturity, input.features.maturity)) } - /// Returns the maximum timelock of the kernels inside of the transaction + /// Returns the maximum time lock of the kernels inside of the transaction pub fn max_kernel_timelock(&self) -> u64 { self.body .kernels() @@ -1331,7 +1331,7 @@ mod test { let mut kernel = create_test_kernel(0.into(), 0); let mut tx = Transaction::new(Vec::new(), Vec::new(), Vec::new(), 0.into(), 0.into()); - // lets add timelocks + // lets add time locks input.features.maturity = 5; kernel.lock_height = 2; tx.body.add_input(input.clone()); diff --git a/base_layer/core/src/transactions/transaction_protocol/sender.rs b/base_layer/core/src/transactions/transaction_protocol/sender.rs index ef57f18af7b..3aae3fd621a 100644 --- a/base_layer/core/src/transactions/transaction_protocol/sender.rs +++ b/base_layer/core/src/transactions/transaction_protocol/sender.rs @@ -58,6 +58,8 @@ use tari_crypto::{ /// This struct contains all the information that a transaction initiator (the sender) will manage throughout the /// Transaction construction process. +// TODO: Investigate necessity to use the 'Serialize' and 'Deserialize' traits here; this could potentially leak +// TODO: information when least expected. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub(super) struct RawTransactionInfo { pub num_recipients: usize, @@ -71,6 +73,7 @@ pub(super) struct RawTransactionInfo { pub change: MicroTari, pub change_output_sender_signature: Option, pub change_script_offset_public_key: Option, + #[serde(skip)] pub unblinded_change_output: Option, pub metadata: TransactionMetadata, pub inputs: Vec, diff --git a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs index 3ba24e9c9cd..b1b3825b5e9 100644 --- a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs +++ b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs @@ -117,7 +117,7 @@ impl SingleReceiverTransactionProtocol { sender_info.script_offset_public_key.clone(), sender_info.sender_metadata_signature.clone(), ); - let _ = output.verify_sender_signature()?; + output.verify_sender_signature()?; Ok(output) } } diff --git a/base_layer/wallet/src/wallet.rs b/base_layer/wallet/src/wallet.rs index 6d5410e69f1..c937af1eb47 100644 --- a/base_layer/wallet/src/wallet.rs +++ b/base_layer/wallet/src/wallet.rs @@ -309,7 +309,7 @@ where source_public_key: &CommsPublicKey, features: OutputFeatures, message: String, - sender_signature: Signature, + sender_metadata_signature: Signature, script_private_key: &PrivateKey, script_offset_public_key: &PublicKey, ) -> Result { @@ -322,7 +322,7 @@ where 0, script_private_key.clone(), script_offset_public_key.clone(), - sender_signature, + sender_metadata_signature, ); let tx_id = self