Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Jul 22, 2024
1 parent 7065470 commit 722c272
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,8 @@ use tari_comms::{multiaddr::Multiaddr, types::CommsPublicKey, CommsNode};
use tari_core::{
consensus::{ConsensusBuilderError, ConsensusConstants, ConsensusManager},
transactions::{
tari_amount::{MicroMinotari, T},
transaction_components::{
encrypted_data::PaymentId,
CodeTemplateRegistration,
OutputFeatures,
OutputType,
SideChainFeature,
UnblindedOutput,
},
tari_amount::MicroMinotari,
transaction_components::{encrypted_data::PaymentId, OutputFeatures, UnblindedOutput},
},
};
use tari_crypto::ristretto::RistrettoSecretKey;
Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_console_wallet/src/ui/state/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub async fn send_register_template_transaction_task(
)
.await;

let sent_tx_id = match result {
let (sent_tx_id, _template_addr) = match result {
Ok(tx_id) => tx_id,
Err(e) => {
error!(target: LOG_TARGET, "failed to register code template: {:?}", e);
Expand All @@ -441,7 +441,7 @@ pub async fn send_register_template_transaction_task(
match event_stream.recv().await {
Ok(event) => {
if let TransactionEvent::TransactionCompletedImmediately(completed_tx_id) = &*event {
if sent_tx_id.0 == *completed_tx_id {
if sent_tx_id == *completed_tx_id {
result_tx.send(UiTransactionSendStatus::TransactionComplete).unwrap();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::{cmp, str::FromStr, sync::Arc};

use log::*;
use minotari_app_utilities::{identity_management, identity_management::load_from_json};
use minotari_app_utilities::{consts, identity_management, identity_management::load_from_json};
use tari_common::{
configuration::bootstrap::ApplicationType,
exit_codes::{ExitCode, ExitError},
Expand Down
26 changes: 11 additions & 15 deletions base_layer/wallet/src/transaction_service/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use tari_common_types::{
};
use tari_comms::types::CommsPublicKey;
use tari_core::{
consensus::{MaxSizeBytes, MaxSizeString},
mempool::FeePerGramStat,
proto,
transactions::{
Expand Down Expand Up @@ -143,14 +142,12 @@ pub enum TransactionServiceRequest {
message: String,
},
RegisterCodeTemplate {
author_public_key: PublicKey,
author_signature: Signature,
template_name: MaxSizeString<32>,
template_name: String,
template_version: u16,
template_type: TemplateType,
build_info: BuildInfo,
binary_sha: MaxSizeBytes<32>,
binary_url: MaxSizeString<255>,
binary_sha: FixedHash,
binary_url: String,
fee_per_gram: MicroMinotari,
sidechain_deployment_key: Option<PrivateKey>,
},
Expand Down Expand Up @@ -638,22 +635,18 @@ impl TransactionServiceHandle {

pub async fn register_code_template(
&mut self,
author_public_key: PublicKey,
author_signature: Signature,
template_name: MaxSizeString<32>,
template_name: String,
template_version: u16,
template_type: TemplateType,
build_info: BuildInfo,
binary_sha: MaxSizeBytes<32>,
binary_url: MaxSizeString<255>,
binary_sha: FixedHash,
binary_url: String,
fee_per_gram: MicroMinotari,
sidechain_deployment_key: Option<PrivateKey>,
) -> Result<TxId, TransactionServiceError> {
) -> Result<(TxId, FixedHash), TransactionServiceError> {
match self
.handle
.call(TransactionServiceRequest::RegisterCodeTemplate {
author_public_key,
author_signature,
template_name,
template_version,
template_type,
Expand All @@ -665,7 +658,10 @@ impl TransactionServiceHandle {
})
.await??
{
TransactionServiceResponse::TransactionSent(tx_id) => Ok(tx_id),
TransactionServiceResponse::CodeRegistrationTransactionSent {
tx_id,
template_address,
} => Ok((tx_id, template_address)),
_ => Err(TransactionServiceError::UnexpectedApiResponse),
}
}
Expand Down
43 changes: 19 additions & 24 deletions base_layer/wallet/src/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use tari_core::{
},
proto::{base_node as base_node_proto, base_node::FetchMatchingUtxos},
transactions::{
key_manager::{TariKeyId, TransactionKeyManagerBranch, TransactionKeyManagerInterface},
key_manager::{SecretTransactionKeyManagerInterface, TariKeyId, TransactionKeyManagerBranch},
tari_amount::MicroMinotari,
transaction_components::{
encrypted_data::PaymentId,
Expand Down Expand Up @@ -233,7 +233,7 @@ where
TBackend: TransactionBackend + 'static,
TWalletBackend: WalletBackend + 'static,
TWalletConnectivity: WalletConnectivityInterface,
TKeyManagerInterface: TransactionKeyManagerInterface,
TKeyManagerInterface: SecretTransactionKeyManagerInterface,
{
pub async fn new(
config: TransactionServiceConfig,
Expand Down Expand Up @@ -810,8 +810,6 @@ where
return Ok(());
},
TransactionServiceRequest::RegisterCodeTemplate {
author_public_key,
author_signature,
template_name,
template_version,
template_type,
Expand All @@ -821,28 +819,25 @@ where
fee_per_gram,
sidechain_deployment_key,
} => {
self.register_code_template(
fee_per_gram,
CodeTemplateRegistration {
author_public_key,
author_signature,
template_name: template_name.clone(),
let (tx_id, main_output_hash) = self
.register_code_template(
fee_per_gram,
template_name.to_string(),
template_version,
template_type,
build_info,
binary_sha,
binary_url,
sidechain_deployment_key,
},
UtxoSelectionCriteria::default(),
format!("Template Registration: {}", template_name),
send_transaction_join_handles,
transaction_broadcast_join_handles,
reply_channel.take().expect("Reply channel is not set"),
)
.await?;

return Ok(());
UtxoSelectionCriteria::default(),
format!("Template Registration: {}", template_name),
transaction_broadcast_join_handles,
)
.await?;
Ok(TransactionServiceResponse::CodeRegistrationTransactionSent {
tx_id,
template_address: main_output_hash,
})
},
TransactionServiceRequest::SendShaAtomicSwapTransaction(
destination,
Expand Down Expand Up @@ -1124,7 +1119,7 @@ where
"Received transaction with spend-to-self transaction"
);

let (fee, transaction) = self
let (fee, transaction, _template_addr) = self
.resources
.output_manager_service
.create_pay_to_self_transaction(tx_id, amount, selection_criteria, output_features, fee_per_gram, None)
Expand Down Expand Up @@ -2411,14 +2406,14 @@ where
let author_key = self
.resources
.transaction_key_manager_service
.get_next_key(&TransactionKeyManagerBranch::CodeTemplateAuthor.get_branch_key())
.get_next_key(TransactionKeyManagerBranch::CodeTemplateAuthor.get_branch_key())
.await?;
let (nonce_secret, nonce_pub) = RistrettoPublicKey::random_keypair(&mut OsRng);
let (sidechain_id, sidechain_id_knowledge_proof) = match sidechain_deployment_key {
Some(k) => (
Some(PublicKey::from_secret_key(&k)),
Some(
SchnorrSignature::sign(&k, &author_key.pub_key, &mut OsRng)
SchnorrSignature::sign(&k, author_key.pub_key.as_bytes(), &mut OsRng)
.map_err(|e| TransactionServiceError::SidechainSigningError(e.to_string()))?,
),
),
Expand Down Expand Up @@ -2452,7 +2447,7 @@ where
let author_sig = self
.resources
.transaction_key_manager_service
.sign_raw(&challenge, &author_key.pub_key, nonce_secret)
.sign_raw(&challenge, &author_key.key_id, nonce_secret)
.await
.map_err(|e| TransactionServiceError::SidechainSigningError(e.to_string()))?;

Expand Down
2 changes: 1 addition & 1 deletion common/src/build/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl StaticApplicationInfo {
)?;
writeln!(
file,
"{}",
r#"#[allow(dead_code)] pub const APP_AUTHORS: &str = "{}";"#,
self.manifest
.workspace
.as_ref()
Expand Down

0 comments on commit 722c272

Please sign in to comment.