diff --git a/base_layer/core/src/transactions/transaction_components/output_features.rs b/base_layer/core/src/transactions/transaction_components/output_features.rs index 609008e591..4c4e917b9b 100644 --- a/base_layer/core/src/transactions/transaction_components/output_features.rs +++ b/base_layer/core/src/transactions/transaction_components/output_features.rs @@ -281,8 +281,8 @@ impl OutputFeatures { } } - pub fn for_contract_definition(commitment: &Commitment, definition: ContractDefinition) -> OutputFeatures { - let contract_id = definition.calculate_contract_id(commitment); + pub fn for_contract_definition(definition: ContractDefinition) -> OutputFeatures { + let contract_id = definition.calculate_contract_id(); Self { output_type: OutputType::ContractDefinition, diff --git a/base_layer/core/src/transactions/transaction_components/side_chain/contract_definition.rs b/base_layer/core/src/transactions/transaction_components/side_chain/contract_definition.rs index 7dac0b8787..426b12cb55 100644 --- a/base_layer/core/src/transactions/transaction_components/side_chain/contract_definition.rs +++ b/base_layer/core/src/transactions/transaction_components/side_chain/contract_definition.rs @@ -23,7 +23,7 @@ use std::io::{Error, Read, Write}; use serde::{Deserialize, Serialize}; -use tari_common_types::types::{Commitment, FixedHash, PublicKey}; +use tari_common_types::types::{FixedHash, PublicKey}; use crate::{ consensus::{ConsensusDecoding, ConsensusEncoding, ConsensusEncodingSized, ConsensusHashWriter, MaxSizeVec}, @@ -49,12 +49,8 @@ impl ContractDefinition { } } - pub fn calculate_contract_id(&self, commitment: &Commitment) -> FixedHash { - ConsensusHashWriter::default() - .chain(commitment) - .chain(self) - .finalize() - .into() + pub fn calculate_contract_id(&self) -> FixedHash { + ConsensusHashWriter::default().chain(self).finalize().into() } } diff --git a/base_layer/core/src/validation/dan_validators/test_helpers.rs b/base_layer/core/src/validation/dan_validators/test_helpers.rs index bee5d91800..11172ee32d 100644 --- a/base_layer/core/src/validation/dan_validators/test_helpers.rs +++ b/base_layer/core/src/validation/dan_validators/test_helpers.rs @@ -23,7 +23,6 @@ use std::convert::TryInto; use tari_common_types::types::{FixedHash, PublicKey, Signature}; -use tari_crypto::commitment::HomomorphicCommitmentFactory; use tari_p2p::Network; use super::TxDanLayerValidator; @@ -53,7 +52,6 @@ use crate::{ Transaction, UnblindedOutput, }, - CryptoFactories, }, txn_schema, validation::{dan_validators::DanLayerValidationError, MempoolTransactionValidation, ValidationError}, @@ -159,11 +157,8 @@ pub fn create_contract_definition_schema(input: UnblindedOutput) -> (FixedHash, public_functions: vec![], }, }; - let commitment = CryptoFactories::default() - .commitment - .commit(&input.spending_key, &input.value.into()); - let contract_id = definition.calculate_contract_id(&commitment); - let definition_features = OutputFeatures::for_contract_definition(&commitment, definition); + let contract_id = definition.calculate_contract_id(); + let definition_features = OutputFeatures::for_contract_definition(definition); let tx_schema = txn_schema!(from: vec![input], to: vec![0.into()], fee: 5.into(), lock: 0, features: definition_features); diff --git a/base_layer/wallet/src/assets/asset_manager.rs b/base_layer/wallet/src/assets/asset_manager.rs index a926fd6141..75667bc00a 100644 --- a/base_layer/wallet/src/assets/asset_manager.rs +++ b/base_layer/wallet/src/assets/asset_manager.rs @@ -25,20 +25,17 @@ use tari_common_types::{ transaction::TxId, types::{Commitment, FixedHash, PublicKey, Signature}, }; -use tari_core::transactions::{ - transaction_components::{ - CommitteeSignatures, - ContractAmendment, - ContractCheckpoint, - ContractDefinition, - ContractUpdateProposal, - OutputFeatures, - OutputType, - SideChainFeatures, - TemplateParameter, - Transaction, - }, - CryptoFactories, +use tari_core::transactions::transaction_components::{ + CommitteeSignatures, + ContractAmendment, + ContractCheckpoint, + ContractDefinition, + ContractUpdateProposal, + OutputFeatures, + OutputType, + SideChainFeatures, + TemplateParameter, + Transaction, }; use crate::{ @@ -309,12 +306,7 @@ impl AssetManager { .create_output_with_features(1.into(), OutputFeatures::default()) .await?; - let commitment = output.generate_commitment(&CryptoFactories::default()); - - output = output.with_features(OutputFeatures::for_contract_definition( - &commitment, - contract_definition, - )); + output = output.with_features(OutputFeatures::for_contract_definition(contract_definition)); let (tx_id, transaction) = self .output_manager diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index ceb4308ddd..e76ce02033 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -676,6 +676,8 @@ where features: OutputFeatures, ) -> Result { let (spending_key, script_private_key) = self.get_spend_and_script_keys().await?; + let input_data = inputs!(PublicKey::from_secret_key(&script_private_key)); + let script = script!(Nop); Ok(UnblindedOutputBuilder::new(value, spending_key) .with_features(features)