Skip to content

Commit

Permalink
Fix small issues related to tari-project#3020
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Jun 22, 2021
1 parent 7901b3c commit 629de9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion base_layer/core/src/transactions/aggregated_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
18 changes: 9 additions & 9 deletions base_layer/core/src/transactions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -71,6 +73,7 @@ pub(super) struct RawTransactionInfo {
pub change: MicroTari,
pub change_output_sender_signature: Option<Signature>,
pub change_script_offset_public_key: Option<PublicKey>,
#[serde(skip)]
pub unblinded_change_output: Option<UnblindedOutput>,
pub metadata: TransactionMetadata,
pub inputs: Vec<TransactionInput>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions base_layer/wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TxId, WalletError> {
Expand All @@ -322,7 +322,7 @@ where
0,
script_private_key.clone(),
script_offset_public_key.clone(),
sender_signature,
sender_metadata_signature,
);

let tx_id = self
Expand Down

0 comments on commit 629de9f

Please sign in to comment.