diff --git a/.cargo/config.toml b/.cargo/config.toml index 235745ca22..b130469b5f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,3 +3,13 @@ linker = "aarch64-linux-gnu-gcc" [target.riscv64gc-unknown-linux-gnu] linker = "riscv64-linux-gnu-gcc" + + +[alias] +ci-fmt = "fmt --all -- --check" +ci-fmt-fix = "fmt --all" +ci-clippy = "lints clippy --all-targets --all-features" +ci-test-compile = "test --no-run --workspace --all-features --no-default-features" +ci-test = "nextest run --all-features --release --workspace --exclude tari_integration_tests --profile ci" +ci-cucumber = "test --all-features --release --package integration_tests" +#ci-check = "check --workspace --release --all-features --all-targets --lock \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 118e7f5828..1524bbe225 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3185,7 +3185,6 @@ dependencies = [ "tari_key_manager", "tari_libtor", "tari_p2p", - "tari_script", "tari_shutdown", "tari_utilities", "thiserror", diff --git a/applications/minotari_app_grpc/proto/wallet.proto b/applications/minotari_app_grpc/proto/wallet.proto index 5ddf2dbfab..ae049f99dc 100644 --- a/applications/minotari_app_grpc/proto/wallet.proto +++ b/applications/minotari_app_grpc/proto/wallet.proto @@ -31,97 +31,96 @@ import "network.proto"; // The gRPC interface for interacting with the wallet. service Wallet { - // This returns the current version - rpc GetVersion (GetVersionRequest) returns (GetVersionResponse); - // This checks if the wallet is healthy and running - rpc CheckConnectivity(GetConnectivityRequest) returns (CheckConnectivityResponse); - // Check for new updates - rpc CheckForUpdates (Empty) returns (SoftwareUpdate); - // This returns the identity information - rpc Identify (GetIdentityRequest) returns (GetIdentityResponse); - // This returns the tari address - rpc GetAddress (Empty) returns (GetAddressResponse); - // Send Minotari to a number of recipients - rpc Transfer (TransferRequest) returns (TransferResponse); - // Returns the transaction details for the given transaction IDs - rpc GetTransactionInfo (GetTransactionInfoRequest) returns (GetTransactionInfoResponse); - // Returns all transactions' details - rpc GetCompletedTransactions (GetCompletedTransactionsRequest) returns (stream GetCompletedTransactionsResponse); - // Returns the balance - rpc GetBalance (GetBalanceRequest) returns (GetBalanceResponse); - // Returns unspent amounts - rpc GetUnspentAmounts (Empty) returns (GetUnspentAmountsResponse); - // Request the wallet perform a coinsplit - rpc CoinSplit (CoinSplitRequest) returns (CoinSplitResponse); - // Import Utxo to wallet - rpc ImportUtxos (ImportUtxosRequest) returns (ImportUtxosResponse); - // Get Base Node network connectivity status - rpc GetNetworkStatus(Empty) returns (NetworkStatusResponse); - // List currently connected peers - rpc ListConnectedPeers(Empty) returns (ListConnectedPeersResponse); - // Cancel pending transaction - rpc CancelTransaction (CancelTransactionRequest) returns (CancelTransactionResponse); - // Will trigger a complete revalidation of all wallet outputs. - rpc RevalidateAllTransactions (RevalidateRequest) returns (RevalidateResponse); - // Will trigger a validation of all wallet outputs. - rpc ValidateAllTransactions (ValidateRequest) returns (ValidateResponse); - // This will send a XTR SHA Atomic swap transaction - rpc SendShaAtomicSwapTransaction(SendShaAtomicSwapRequest) returns (SendShaAtomicSwapResponse); - // This will create a burn transaction - rpc CreateBurnTransaction(CreateBurnTransactionRequest) returns (CreateBurnTransactionResponse); - // This will claim a XTR SHA Atomic swap transaction - rpc ClaimShaAtomicSwapTransaction(ClaimShaAtomicSwapRequest) returns (ClaimShaAtomicSwapResponse); - // This will claim a HTLC refund transaction - rpc ClaimHtlcRefundTransaction(ClaimHtlcRefundRequest) returns (ClaimHtlcRefundResponse); - // Creates a transaction with a template registration output - rpc CreateTemplateRegistration(CreateTemplateRegistrationRequest) returns (CreateTemplateRegistrationResponse); - rpc SetBaseNode(SetBaseNodeRequest) returns (SetBaseNodeResponse); - - rpc StreamTransactionEvents(TransactionEventRequest) returns (stream TransactionEventResponse); - - rpc RegisterValidatorNode(RegisterValidatorNodeRequest) returns (RegisterValidatorNodeResponse); -} - -message GetVersionRequest { } + // This returns the current version + rpc GetVersion (GetVersionRequest) returns (GetVersionResponse); + // This checks if the wallet is healthy and running + rpc CheckConnectivity(GetConnectivityRequest) returns (CheckConnectivityResponse); + // Check for new updates + rpc CheckForUpdates (Empty) returns (SoftwareUpdate); + // This returns the identity information + rpc Identify (GetIdentityRequest) returns (GetIdentityResponse); + // This returns the tari address + rpc GetAddress (Empty) returns (GetAddressResponse); + // Send Minotari to a number of recipients + rpc Transfer (TransferRequest) returns (TransferResponse); + // Returns the transaction details for the given transaction IDs + rpc GetTransactionInfo (GetTransactionInfoRequest) returns (GetTransactionInfoResponse); + // Returns all transactions' details + rpc GetCompletedTransactions (GetCompletedTransactionsRequest) returns (stream GetCompletedTransactionsResponse); + // Returns the balance + rpc GetBalance (GetBalanceRequest) returns (GetBalanceResponse); + // Returns unspent amounts + rpc GetUnspentAmounts (Empty) returns (GetUnspentAmountsResponse); + // Request the wallet perform a coinsplit + rpc CoinSplit (CoinSplitRequest) returns (CoinSplitResponse); + // Import Utxo to wallet + rpc ImportUtxos (ImportUtxosRequest) returns (ImportUtxosResponse); + // Get Base Node network connectivity status + rpc GetNetworkStatus(Empty) returns (NetworkStatusResponse); + // List currently connected peers + rpc ListConnectedPeers(Empty) returns (ListConnectedPeersResponse); + // Cancel pending transaction + rpc CancelTransaction (CancelTransactionRequest) returns (CancelTransactionResponse); + // Will trigger a complete revalidation of all wallet outputs. + rpc RevalidateAllTransactions (RevalidateRequest) returns (RevalidateResponse); + // Will trigger a validation of all wallet outputs. + rpc ValidateAllTransactions (ValidateRequest) returns (ValidateResponse); + // This will send a XTR SHA Atomic swap transaction + rpc SendShaAtomicSwapTransaction(SendShaAtomicSwapRequest) returns (SendShaAtomicSwapResponse); + // This will create a burn transaction + rpc CreateBurnTransaction(CreateBurnTransactionRequest) returns (CreateBurnTransactionResponse); + // This will claim a XTR SHA Atomic swap transaction + rpc ClaimShaAtomicSwapTransaction(ClaimShaAtomicSwapRequest) returns (ClaimShaAtomicSwapResponse); + // This will claim a HTLC refund transaction + rpc ClaimHtlcRefundTransaction(ClaimHtlcRefundRequest) returns (ClaimHtlcRefundResponse); + // Creates a transaction with a template registration output + rpc CreateTemplateRegistration(CreateTemplateRegistrationRequest) returns (CreateTemplateRegistrationResponse); + rpc SetBaseNode(SetBaseNodeRequest) returns (SetBaseNodeResponse); + + rpc StreamTransactionEvents(TransactionEventRequest) returns (stream TransactionEventResponse); + + rpc RegisterValidatorNode(RegisterValidatorNodeRequest) returns (RegisterValidatorNodeResponse); +} + +message GetVersionRequest {} message GetVersionResponse { - string version = 1; + string version = 1; } message GetAddressResponse { - bytes address = 1; + bytes address = 1; } message TransferRequest { - repeated PaymentRecipient recipients = 1; + repeated PaymentRecipient recipients = 1; } message SendShaAtomicSwapRequest { - PaymentRecipient recipient = 1; + PaymentRecipient recipient = 1; } message CreateBurnTransactionRequest{ - uint64 amount = 1; - uint64 fee_per_gram = 2; - string message = 3; - bytes claim_public_key = 4; - bytes sidechain_id = 5; - Signature sidechain_id_knowledge_proof = 6; + uint64 amount = 1; + uint64 fee_per_gram = 2; + string message = 3; + bytes claim_public_key = 4; + bytes sidechain_deployment_key = 5; } message PaymentRecipient { - string address = 1; - uint64 amount = 2; - uint64 fee_per_gram = 3; - string message = 4; - enum PaymentType { - STANDARD_MIMBLEWIMBLE = 0; - ONE_SIDED = 1; - ONE_SIDED_TO_STEALTH_ADDRESS = 2; - } - PaymentType payment_type = 5; + string address = 1; + uint64 amount = 2; + uint64 fee_per_gram = 3; + string message = 4; + enum PaymentType { + STANDARD_MIMBLEWIMBLE = 0; + ONE_SIDED = 1; + ONE_SIDED_TO_STEALTH_ADDRESS = 2; + } + PaymentType payment_type = 5; } message TransferResponse { @@ -129,166 +128,172 @@ message TransferResponse { } message SendShaAtomicSwapResponse { - uint64 transaction_id = 1; - string pre_image = 2; - string output_hash = 3; - bool is_success = 4; - string failure_message = 5; + uint64 transaction_id = 1; + string pre_image = 2; + string output_hash = 3; + bool is_success = 4; + string failure_message = 5; } message CreateBurnTransactionResponse{ - uint64 transaction_id = 1; - bool is_success = 2; - string failure_message = 3; - bytes commitment = 4; - CommitmentSignature ownership_proof = 5; - bytes range_proof = 6; - bytes reciprocal_claim_public_key = 7; + uint64 transaction_id = 1; + bool is_success = 2; + string failure_message = 3; + bytes commitment = 4; + CommitmentSignature ownership_proof = 5; + bytes range_proof = 6; + bytes reciprocal_claim_public_key = 7; } message TransferResult { - string address = 1; - uint64 transaction_id = 2; - bool is_success = 3; - string failure_message = 4; + string address = 1; + uint64 transaction_id = 2; + bool is_success = 3; + string failure_message = 4; } message ClaimShaAtomicSwapRequest{ - string output = 1; - string pre_image = 2; - uint64 fee_per_gram = 3; + string output = 1; + string pre_image = 2; + uint64 fee_per_gram = 3; } message ClaimShaAtomicSwapResponse { - TransferResult results = 1; + TransferResult results = 1; } message ClaimHtlcRefundRequest{ - string output_hash = 1; - uint64 fee_per_gram = 2; + string output_hash = 1; + uint64 fee_per_gram = 2; } message ClaimHtlcRefundResponse { - TransferResult results = 1; + TransferResult results = 1; } message GetTransactionInfoRequest { - repeated uint64 transaction_ids = 1; + repeated uint64 transaction_ids = 1; } message GetTransactionInfoResponse { - repeated TransactionInfo transactions = 1; + repeated TransactionInfo transactions = 1; } message TransactionInfo { - uint64 tx_id = 1; - bytes source_address = 2; - bytes dest_address = 3; - TransactionStatus status = 4; - TransactionDirection direction = 5; - uint64 amount = 6; - uint64 fee = 7; - bool is_cancelled = 8; - bytes excess_sig = 9; - uint64 timestamp = 10; - string message = 11; + uint64 tx_id = 1; + bytes source_address = 2; + bytes dest_address = 3; + TransactionStatus status = 4; + TransactionDirection direction = 5; + uint64 amount = 6; + uint64 fee = 7; + bool is_cancelled = 8; + bytes excess_sig = 9; + uint64 timestamp = 10; + string message = 11; } enum TransactionDirection { - TRANSACTION_DIRECTION_UNKNOWN = 0; - TRANSACTION_DIRECTION_INBOUND = 1; - TRANSACTION_DIRECTION_OUTBOUND = 2; + TRANSACTION_DIRECTION_UNKNOWN = 0; + TRANSACTION_DIRECTION_INBOUND = 1; + TRANSACTION_DIRECTION_OUTBOUND = 2; } enum TransactionStatus { - // This transaction has been completed between the parties but has not been broadcast to the base layer network. - TRANSACTION_STATUS_COMPLETED = 0; - // This transaction has been broadcast to the base layer network and is currently in one or more base node mempools. - TRANSACTION_STATUS_BROADCAST = 1; - // This transaction has been mined and included in a block. - TRANSACTION_STATUS_MINED_UNCONFIRMED = 2; - // This transaction was generated as part of importing a spendable UTXO - TRANSACTION_STATUS_IMPORTED = 3; - // This transaction is still being negotiated by the parties - TRANSACTION_STATUS_PENDING = 4; - // This is a created Coinbase Transaction - TRANSACTION_STATUS_COINBASE = 5; - // This transaction is mined and confirmed at the current base node's height - TRANSACTION_STATUS_MINED_CONFIRMED = 6; - // The transaction was rejected by the mempool - TRANSACTION_STATUS_REJECTED = 7; - // This is faux transaction mainly for one-sided transaction outputs or wallet recovery outputs have been found - TRANSACTION_STATUS_ONE_SIDED_UNCONFIRMED = 8; - // All Imported and FauxUnconfirmed transactions will end up with this status when the outputs have been confirmed - TRANSACTION_STATUS_ONE_SIDED_CONFIRMED = 9; - // This transaction is still being queued for sending - TRANSACTION_STATUS_QUEUED = 10; - // The transaction was not found by the wallet its in transaction database - TRANSACTION_STATUS_NOT_FOUND = 11; - // This is Coinbase transaction that is detected from chain - TRANSACTION_STATUS_COINBASE_UNCONFIRMED = 12; - // This is Coinbase transaction that is detected from chain - TRANSACTION_STATUS_COINBASE_CONFIRMED = 13; - // This is Coinbase transaction that is not currently detected as mined - TRANSACTION_STATUS_COINBASE_NOT_IN_BLOCK_CHAIN = 14; -} - -message GetCompletedTransactionsRequest { } + // This transaction has been completed between the parties but has not been broadcast to the base layer network. + TRANSACTION_STATUS_COMPLETED = 0; + // This transaction has been broadcast to the base layer network and is currently in one or more base node mempools. + TRANSACTION_STATUS_BROADCAST = 1; + // This transaction has been mined and included in a block. + TRANSACTION_STATUS_MINED_UNCONFIRMED = 2; + // This transaction was generated as part of importing a spendable UTXO + TRANSACTION_STATUS_IMPORTED = 3; + // This transaction is still being negotiated by the parties + TRANSACTION_STATUS_PENDING = 4; + // This is a created Coinbase Transaction + TRANSACTION_STATUS_COINBASE = 5; + // This transaction is mined and confirmed at the current base node's height + TRANSACTION_STATUS_MINED_CONFIRMED = 6; + // The transaction was rejected by the mempool + TRANSACTION_STATUS_REJECTED = 7; + // This is faux transaction mainly for one-sided transaction outputs or wallet recovery outputs have been found + TRANSACTION_STATUS_ONE_SIDED_UNCONFIRMED = 8; + // All Imported and FauxUnconfirmed transactions will end up with this status when the outputs have been confirmed + TRANSACTION_STATUS_ONE_SIDED_CONFIRMED = 9; + // This transaction is still being queued for sending + TRANSACTION_STATUS_QUEUED = 10; + // The transaction was not found by the wallet its in transaction database + TRANSACTION_STATUS_NOT_FOUND = 11; + // This is Coinbase transaction that is detected from chain + TRANSACTION_STATUS_COINBASE_UNCONFIRMED = 12; + // This is Coinbase transaction that is detected from chain + TRANSACTION_STATUS_COINBASE_CONFIRMED = 13; + // This is Coinbase transaction that is not currently detected as mined + TRANSACTION_STATUS_COINBASE_NOT_IN_BLOCK_CHAIN = 14; +} + +message GetCompletedTransactionsRequest {} message GetCompletedTransactionsResponse { - TransactionInfo transaction = 1; + TransactionInfo transaction = 1; } -message GetBalanceRequest { } +message GetBalanceRequest {} message GetBalanceResponse { - uint64 available_balance = 1; - uint64 pending_incoming_balance = 2; - uint64 pending_outgoing_balance = 3; - uint64 timelocked_balance = 4; + uint64 available_balance = 1; + uint64 pending_incoming_balance = 2; + uint64 pending_outgoing_balance = 3; + uint64 timelocked_balance = 4; } message GetUnspentAmountsResponse { - repeated uint64 amount = 1; + repeated uint64 amount = 1; } message CoinSplitRequest { - uint64 amount_per_split = 1; - uint64 split_count = 2; - uint64 fee_per_gram = 3; - string message = 4; - uint64 lock_height = 5; + uint64 amount_per_split = 1; + uint64 split_count = 2; + uint64 fee_per_gram = 3; + string message = 4; + uint64 lock_height = 5; } message CoinSplitResponse { - uint64 tx_id = 1; + uint64 tx_id = 1; } message ImportUtxosRequest { - repeated UnblindedOutput outputs = 1; + repeated UnblindedOutput outputs = 1; } message ImportUtxosResponse { - repeated uint64 tx_ids = 1; + repeated uint64 tx_ids = 1; } message CreateTemplateRegistrationRequest { - TemplateRegistration template_registration = 1; - uint64 fee_per_gram = 2; + uint64 fee_per_gram = 2; + string template_name = 3; + uint32 template_version = 4; + TemplateType template_type = 5; + BuildInfo build_info = 6; + bytes binary_sha = 7; + string binary_url = 8; + bytes sidechain_deployment_key = 9; } message CreateTemplateRegistrationResponse { - uint64 tx_id = 1; - bytes template_address = 2; + uint64 tx_id = 1; + bytes template_address = 2; } message CancelTransactionRequest { - uint64 tx_id = 1; + uint64 tx_id = 1; } message CancelTransactionResponse { - bool is_success = 1; - string failure_message = 2; + bool is_success = 1; + string failure_message = 2; } message RevalidateRequest{} @@ -300,8 +305,8 @@ message ValidateRequest{} message ValidateResponse{} message SetBaseNodeRequest { - string public_key_hex = 1; - string net_address = 2; + string public_key_hex = 1; + string net_address = 2; } message SetBaseNodeResponse{} @@ -309,12 +314,12 @@ message SetBaseNodeResponse{} message GetConnectivityRequest{} message CheckConnectivityResponse{ - enum OnlineStatus { - Connecting = 0; - Online = 1; - Offline = 2; - } - OnlineStatus status = 1; + enum OnlineStatus { + Connecting = 0; + Online = 1; + Offline = 2; + } + OnlineStatus status = 1; } message TransactionEventRequest{ @@ -322,32 +327,31 @@ message TransactionEventRequest{ } message TransactionEvent { - string event = 1; - string tx_id = 2; - bytes source_address = 3; - bytes dest_address = 4; - string status = 5; - string direction = 6; - uint64 amount = 7; - string message = 8; + string event = 1; + string tx_id = 2; + bytes source_address = 3; + bytes dest_address = 4; + string status = 5; + string direction = 6; + uint64 amount = 7; + string message = 8; } message TransactionEventResponse { - TransactionEvent transaction = 1; + TransactionEvent transaction = 1; } message RegisterValidatorNodeRequest { - bytes validator_node_public_key = 1; - Signature validator_node_signature = 2; - bytes validator_node_claim_public_key = 3; - uint64 fee_per_gram = 4; - string message = 5; - bytes sidechain_id = 6; - Signature sidechain_id_knowledge_proof = 7; + bytes validator_node_public_key = 1; + Signature validator_node_signature = 2; + bytes validator_node_claim_public_key = 3; + uint64 fee_per_gram = 4; + string message = 5; + bytes sidechain_deployment_key = 6; } message RegisterValidatorNodeResponse { - uint64 transaction_id = 1; - bool is_success = 2; - string failure_message = 3; + uint64 transaction_id = 1; + bool is_success = 2; + string failure_message = 3; } diff --git a/applications/minotari_console_wallet/Cargo.toml b/applications/minotari_console_wallet/Cargo.toml index 2485bdd322..e22e709f68 100644 --- a/applications/minotari_console_wallet/Cargo.toml +++ b/applications/minotari_console_wallet/Cargo.toml @@ -17,7 +17,6 @@ tari_crypto = { version = "0.20" } tari_key_manager = { path = "../../base_layer/key_manager" } tari_libtor = { path = "../../infrastructure/libtor", optional = true } tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] } -tari_script = { path = "../../infrastructure/tari_script" } tari_shutdown = { path = "../../infrastructure/shutdown" } tari_utilities = { version = "0.7" } minotari_wallet = { path = "../../base_layer/wallet", features = [ diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index f2403a1236..c3980cb23e 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -54,7 +54,7 @@ use tari_common_types::{ emoji::EmojiId, tari_address::TariAddress, transaction::TxId, - types::{Commitment, FixedHash, PublicKey, Signature}, + types::{Commitment, FixedHash, PrivateKey, PublicKey, Signature}, }; use tari_comms::{ connectivity::{ConnectivityEvent, ConnectivityRequester}, @@ -138,6 +138,7 @@ pub async fn burn_tari( fee_per_gram: u64, amount: MicroMinotari, message: String, + sidechain_deployment_key: Option, ) -> Result<(TxId, BurntProof), CommandError> { wallet_transaction_service .burn_tari( @@ -146,8 +147,7 @@ pub async fn burn_tari( fee_per_gram * uT, message, None, - None, - None, + sidechain_deployment_key, ) .await .map_err(CommandError::TransactionServiceError) @@ -210,8 +210,7 @@ pub async fn register_validator_node( validator_node_public_key: PublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -222,8 +221,7 @@ pub async fn register_validator_node( validator_node_public_key, validator_node_signature, validator_node_claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, selection_criteria, fee_per_gram, message, @@ -474,7 +472,7 @@ pub async fn make_it_rain( ) .await }, - MakeItRainTransactionType::BurnTari => burn_tari(tx_service, fee, amount, msg.clone()) + MakeItRainTransactionType::BurnTari => burn_tari(tx_service, fee, amount, msg.clone(), None) .await .map(|(tx_id, _)| tx_id), }; @@ -691,6 +689,7 @@ pub async fn command_runner( config.fee_per_gram, args.amount, args.message, + None, ) .await { @@ -1031,16 +1030,12 @@ pub async fn command_runner( RistrettoSecretKey::from_vec(&args.validator_node_signature[0])?, ), args.validator_node_claim_public_key.into(), - args.sidechain_id.map(|v| v.into()), - if args.sidechain_id_knowledge_proof_nonce.is_none() || - args.sidechain_id_knowledge_proof_sig.is_empty() - { + if args.sidechain_deployment_key.is_empty() { None } else { - Some(Signature::new( - args.sidechain_id_knowledge_proof_nonce.as_ref().unwrap().clone().into(), - RistrettoSecretKey::from_vec(&args.sidechain_id_knowledge_proof_sig[0])?, - )) + Some(RistrettoSecretKey::from_canonical_bytes( + &args.sidechain_deployment_key[0], + )?) }, UtxoSelectionCriteria::default(), config.fee_per_gram * uT, diff --git a/applications/minotari_console_wallet/src/cli.rs b/applications/minotari_console_wallet/src/cli.rs index debc8715e8..fe0bb377ac 100644 --- a/applications/minotari_console_wallet/src/cli.rs +++ b/applications/minotari_console_wallet/src/cli.rs @@ -304,10 +304,8 @@ pub struct RegisterValidatorNodeArgs { #[clap(long, parse(try_from_str = parse_hex), required = true)] pub validator_node_signature: Vec>, pub validator_node_claim_public_key: UniPublicKey, - pub sidechain_id: Option, - pub sidechain_id_knowledge_proof_nonce: Option, - #[clap(long, parse(try_from_str = parse_hex), required= false)] - pub sidechain_id_knowledge_proof_sig: Vec>, + #[clap(long, parse(try_from_str = parse_hex), required = false)] + pub sidechain_deployment_key: Vec>, #[clap(short, long, default_value = "Registering VN")] pub message: String, } diff --git a/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs b/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs index b7b02ab558..3ded0ee040 100644 --- a/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -92,23 +92,17 @@ use minotari_wallet::{ use tari_common_types::{ tari_address::TariAddress, transaction::TxId, - types::{BlockHash, PublicKey, Signature}, + types::{BlockHash, PrivateKey, PublicKey, Signature}, }; use tari_comms::{multiaddr::Multiaddr, types::CommsPublicKey, CommsNode}; use tari_core::{ consensus::{ConsensusBuilderError, ConsensusConstants, ConsensusManager}, transactions::{ - tari_amount::{MicroMinotari, T}, - transaction_components::{ - CodeTemplateRegistration, - OutputFeatures, - OutputType, - SideChainFeature, - UnblindedOutput, - }, + tari_amount::MicroMinotari, + transaction_components::{OutputFeatures, UnblindedOutput}, }, }; -use tari_script::script; +use tari_crypto::ristretto::RistrettoSecretKey; use tari_utilities::{hex::Hex, ByteArray}; use tokio::{sync::broadcast, task}; use tonic::{Request, Response, Status}; @@ -601,25 +595,14 @@ impl wallet_server::Wallet for WalletGrpcServer { .map_err(|e| Status::invalid_argument(e.to_string()))?, ) }, - if message.sidechain_id.is_empty() { + if message.sidechain_deployment_key.is_empty() { None } else { Some( - PublicKey::from_canonical_bytes(&message.sidechain_id) + PrivateKey::from_canonical_bytes(&message.sidechain_deployment_key) .map_err(|e| Status::invalid_argument(e.to_string()))?, ) }, - if message.sidechain_id_knowledge_proof.is_none() { - None - } else { - Some( - message - .sidechain_id_knowledge_proof - .unwrap() - .try_into() - .map_err(Status::invalid_argument)?, - ) - }, ) .await { @@ -958,50 +941,46 @@ impl wallet_server::Wallet for WalletGrpcServer { &self, request: Request, ) -> Result, Status> { - let mut output_manager = self.wallet.output_manager_service.clone(); + // let mut output_manager = self.wallet.output_manager_service.clone(); let mut transaction_service = self.wallet.transaction_service.clone(); let message = request.into_inner(); - let template_registration = CodeTemplateRegistration::try_from( - message - .template_registration - .ok_or_else(|| Status::invalid_argument("template_registration is empty"))?, - ) - .map_err(|e| Status::invalid_argument(format!("template_registration is invalid: {}", e)))?; - let fee_per_gram = message.fee_per_gram; - - let message = format!("Template registration {}", template_registration.template_name); - let mut output = output_manager - .create_output_with_features(1 * T, OutputFeatures { - output_type: OutputType::CodeTemplateRegistration, - sidechain_feature: Some(SideChainFeature::CodeTemplateRegistration(template_registration)), - ..Default::default() - }) - .await - .map_err(|e| Status::internal(e.to_string()))?; - - output = output.with_script(script![Nop]); - - let (tx_id, transaction) = output_manager - .create_send_to_self_with_output(vec![output], fee_per_gram.into(), UtxoSelectionCriteria::default()) - .await - .map_err(|e| Status::internal(e.to_string()))?; - - debug!( - target: LOG_TARGET, - "Template registration transaction: {:?}", transaction - ); - - let reg_output = transaction - .body - .outputs() - .iter() - .find(|o| o.features.output_type == OutputType::CodeTemplateRegistration) - .ok_or_else(|| Status::internal("No code template registration output!"))?; - let template_address = reg_output.hash(); - - transaction_service - .submit_transaction(tx_id, transaction, 0.into(), message) + let fee_per_gram = message.fee_per_gram.into(); + + let (tx_id, template_address) = transaction_service + .register_code_template( + message.template_name.clone(), + message + .template_version + .try_into() + .map_err(|_| Status::invalid_argument("template version is too large for a u16"))?, + if let Some(tt) = message.template_type { + tt.try_into() + .map_err(|_| Status::invalid_argument("template type is invalid"))? + } else { + return Err(Status::invalid_argument("template type is missing")); + }, + if let Some(bi) = message.build_info { + bi.try_into() + .map_err(|_| Status::invalid_argument("build info is invalid"))? + } else { + return Err(Status::invalid_argument("build info is missing")); + }, + message + .binary_sha + .try_into() + .map_err(|_| Status::invalid_argument("binary sha is malformed"))?, + message.binary_url, + fee_per_gram, + if message.sidechain_deployment_key.is_empty() { + None + } else { + Some( + RistrettoSecretKey::from_canonical_bytes(&message.sidechain_deployment_key) + .map_err(|_| Status::invalid_argument("sidechain_deployment_key is malformed"))?, + ) + }, + ) .await .map_err(|e| Status::internal(e.to_string()))?; @@ -1027,22 +1006,15 @@ impl wallet_server::Wallet for WalletGrpcServer { let validator_node_claim_public_key = PublicKey::from_canonical_bytes(&request.validator_node_claim_public_key) .map_err(|_| Status::invalid_argument("Claim public key is malformed"))?; - let sidechain_id = if request.sidechain_id.is_empty() { + let sidechain_key = if request.sidechain_deployment_key.is_empty() { None } else { Some( - PublicKey::from_canonical_bytes(&request.sidechain_id) + PrivateKey::from_canonical_bytes(&request.sidechain_deployment_key) .map_err(|_| Status::invalid_argument("sidechain_id is malformed"))?, ) }; - let sidechain_id_knowledge_proof = request - .sidechain_id_knowledge_proof - .map(|v| { - v.try_into() - .map_err(|_| Status::invalid_argument("SidechainId knowledge proof is malformed")) - }) - .transpose()?; let constants = self.get_consensus_constants().map_err(|e| { error!(target: LOG_TARGET, "Failed to get consensus constants: {}", e); Status::internal("failed to fetch consensus constants") @@ -1054,8 +1026,7 @@ impl wallet_server::Wallet for WalletGrpcServer { validator_node_public_key, validator_node_signature, validator_node_claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_key, UtxoSelectionCriteria::default(), request.fee_per_gram.into(), request.message, diff --git a/applications/minotari_console_wallet/src/ui/components/burn_tab.rs b/applications/minotari_console_wallet/src/ui/components/burn_tab.rs index b83d1ea34b..2cf14314f0 100644 --- a/applications/minotari_console_wallet/src/ui/components/burn_tab.rs +++ b/applications/minotari_console_wallet/src/ui/components/burn_tab.rs @@ -32,8 +32,7 @@ pub struct BurnTab { burn_input_mode: BurnInputMode, burnt_proof_filepath_field: String, claim_public_key_field: String, - sidechain_id_field: String, - sidechain_id_knowledge_proof_field: String, + sidechain_key_field: String, amount_field: String, fee_field: String, message_field: String, @@ -53,8 +52,7 @@ impl BurnTab { burn_input_mode: BurnInputMode::None, burnt_proof_filepath_field: String::new(), claim_public_key_field: String::new(), - sidechain_id_field: String::new(), - sidechain_id_knowledge_proof_field: String::new(), + sidechain_key_field: String::new(), amount_field: String::new(), fee_field: app_state.get_default_fee_per_gram().as_u64().to_string(), message_field: String::new(), @@ -147,25 +145,13 @@ impl BurnTab { .block(Block::default().borders(Borders::ALL).title("To (C)laim Public Key:")); f.render_widget(claim_public_key_input, vert_chunks[2]); - let sidechain_id_input = Paragraph::new(self.sidechain_id_field.as_ref()) + let sidechain_key_input = Paragraph::new(self.sidechain_key_field.as_ref()) .style(match self.burn_input_mode { BurnInputMode::ClaimPublicKey => Style::default().fg(Color::Magenta), _ => Style::default(), }) - .block(Block::default().borders(Borders::ALL).title("Sidechain ID:")); - f.render_widget(sidechain_id_input, vert_chunks[3]); - - let sidechain_id_knowledge_proof_input = Paragraph::new(self.sidechain_id_knowledge_proof_field.as_ref()) - .style(match self.burn_input_mode { - BurnInputMode::ClaimPublicKey => Style::default().fg(Color::Magenta), - _ => Style::default(), - }) - .block( - Block::default() - .borders(Borders::ALL) - .title("Sidechain ID Knowledge Proof:"), - ); - f.render_widget(sidechain_id_knowledge_proof_input, vert_chunks[4]); + .block(Block::default().borders(Borders::ALL).title("Sidechain Key:")); + f.render_widget(sidechain_key_input, vert_chunks[3]); let amount_fee_layout = Layout::default() .direction(Direction::Horizontal) @@ -326,16 +312,10 @@ impl BurnTab { Some(self.claim_public_key_field.clone()) }; - let sidechain_id = if self.sidechain_id_field.is_empty() { - None - } else { - Some(self.sidechain_id_field.clone()) - }; - - let sidechain_id_knowledge_proof = if self.sidechain_id_knowledge_proof_field.is_empty() { + let sidechain_key = if self.sidechain_key_field.is_empty() { None } else { - Some(self.sidechain_id_knowledge_proof_field.clone()) + Some(self.sidechain_key_field.clone()) }; let (tx, rx) = watch::channel(UiTransactionBurnStatus::Initiated); @@ -350,8 +330,7 @@ impl BurnTab { UtxoSelectionCriteria::default(), fee_per_gram, self.message_field.clone(), - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_key, tx, )) { Err(e) => { diff --git a/applications/minotari_console_wallet/src/ui/state/app_state.rs b/applications/minotari_console_wallet/src/ui/state/app_state.rs index a9a1614603..d860286e1e 100644 --- a/applications/minotari_console_wallet/src/ui/state/app_state.rs +++ b/applications/minotari_console_wallet/src/ui/state/app_state.rs @@ -46,7 +46,7 @@ use tari_common::configuration::Network; use tari_common_types::{ tari_address::TariAddress, transaction::{TransactionDirection, TransactionStatus, TxId}, - types::{PublicKey, Signature}, + types::{PrivateKey, PublicKey}, }; use tari_comms::{ connectivity::ConnectivityEventRx, @@ -62,10 +62,7 @@ use tari_core::transactions::{ }; use tari_crypto::ristretto::RistrettoSecretKey; use tari_shutdown::ShutdownSignal; -use tari_utilities::{ - hex::{from_hex, Hex}, - ByteArray, -}; +use tari_utilities::hex::{from_hex, Hex}; use tokio::{ sync::{broadcast, watch, RwLock}, task, @@ -402,8 +399,7 @@ impl AppState { selection_criteria: UtxoSelectionCriteria, fee_per_gram: u64, message: String, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, result_tx: watch::Sender, ) -> Result<(), UiError> { let inner = self.inner.write().await; @@ -431,29 +427,13 @@ impl AppState { }, }; - let sidechain_id_pub = match sidechain_id { + let sidechain_deploy_key = match sidechain_deployment_key { None => None, - Some(sidechain_id) => match PublicKey::from_hex(sidechain_id.as_str()) { + Some(sidechain_id) => match PrivateKey::from_hex(sidechain_id.as_str()) { Ok(s) => Some(s), Err(_) => return Err(UiError::PublicKeyParseError), }, }; - let sc_knowledge_proof = match sidechain_id_knowledge_proof { - None => None, - Some(s) => match Vec::::from_hex(s.as_str()) { - Ok(bytes) => { - if bytes.len() < 64 { - return Err(UiError::SignatureParseError); - } - Some(Signature::new( - PublicKey::from_canonical_bytes(&bytes[0..32]).map_err(|_| UiError::SignatureParseError)?, - RistrettoSecretKey::from_canonical_bytes(&bytes[32..]) - .map_err(|_| UiError::SignatureParseError)?, - )) - }, - Err(_) => return Err(UiError::SignatureParseError), - }, - }; send_burn_transaction_task( burn_proof_filepath, @@ -462,8 +442,7 @@ impl AppState { selection_criteria, message, fee_per_gram, - sidechain_id_pub, - sc_knowledge_proof, + sidechain_deploy_key, tx_service_handle, inner.wallet.db.clone(), result_tx, diff --git a/applications/minotari_console_wallet/src/ui/state/tasks.rs b/applications/minotari_console_wallet/src/ui/state/tasks.rs index 158cdf6010..6160d0e51f 100644 --- a/applications/minotari_console_wallet/src/ui/state/tasks.rs +++ b/applications/minotari_console_wallet/src/ui/state/tasks.rs @@ -22,32 +22,25 @@ use std::{convert::TryFrom, path::PathBuf}; -use blake2::Blake2b; -use digest::consts::U64; use log::{error, warn}; use minotari_wallet::{ output_manager_service::UtxoSelectionCriteria, storage::{database::WalletDatabase, sqlite_db::wallet::WalletSqliteDatabase}, transaction_service::handle::{TransactionEvent, TransactionSendStatus, TransactionServiceHandle}, }; -use rand::{random, rngs::OsRng}; +use rand::random; use tari_common_types::{ tari_address::TariAddress, - types::{PublicKey, Signature}, + types::{FixedHash, PrivateKey, PublicKey}, }; use tari_core::{ consensus::{MaxSizeBytes, MaxSizeString}, transactions::{ tari_amount::MicroMinotari, - transaction_components, transaction_components::{BuildInfo, OutputFeatures, TemplateType}, }, }; -use tari_crypto::{ - keys::PublicKey as PublicKeyTrait, - ristretto::{RistrettoPublicKey, RistrettoSecretKey}, -}; -use tari_key_manager::key_manager::KeyManager; +use tari_crypto::ristretto::RistrettoSecretKey; use tari_utilities::{hex::Hex, ByteArray}; use tokio::sync::{broadcast, watch}; @@ -250,8 +243,7 @@ pub async fn send_burn_transaction_task( selection_criteria: UtxoSelectionCriteria, message: String, fee_per_gram: MicroMinotari, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, mut transaction_service_handle: TransactionServiceHandle, db: WalletDatabase, result_tx: watch::Sender, @@ -270,8 +262,7 @@ pub async fn send_burn_transaction_task( fee_per_gram, message, claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, ) .await { @@ -457,68 +448,28 @@ pub async fn send_register_template_transaction_task( }, }; - // ---------------------------------------------------------------------------- - // signing and sending code template registration request - // ---------------------------------------------------------------------------- - - let mut km = KeyManager::>::new(); - - let author_private_key = match km.next_key() { - Ok(secret_key) => secret_key.key, - Err(e) => { - error!(target: LOG_TARGET, "failed to generate key: {}", e); - result_tx.send(UiTransactionSendStatus::Error(e.to_string())).unwrap(); - return; - }, - }; - - let author_public_key = PublicKey::from_secret_key(&author_private_key); - let (secret_nonce, public_nonce) = PublicKey::random_keypair(&mut OsRng); - - let pub_validator_key = sidechain_id_key.map(PublicKey::from_secret_key); - - let sidechain_id_knowledge_proof = match sidechain_id_key { - Some(key) => Some(match Signature::sign(key, author_public_key.to_vec(), &mut OsRng) { - Ok(signature) => signature, - Err(e) => { - error!(target: LOG_TARGET, "failed to sign network knowledge proof: {}", e); - result_tx.send(UiTransactionSendStatus::Error(e.to_string())).unwrap(); - return; - }, - }), - None => None, - }; - - let challenge = transaction_components::CodeTemplateRegistration::create_challenge_from_components( - &author_public_key, - &public_nonce, - &binary_sha, - pub_validator_key.as_ref(), - ); - - let author_signature = Signature::sign_raw_uniform(&author_private_key, secret_nonce, &challenge) - .expect("Sign cannot fail with 32-byte challenge and a RistrettoPublicKey"); - - // ---------------------------------------------------------------------------- - // ============================================================================ - // ---------------------------------------------------------------------------- - let result = transaction_service_handle .register_code_template( - author_public_key, - author_signature, - template_name, + template_name.to_string(), template_version, template_type, BuildInfo { repo_url: repository_url, commit_hash: repository_commit_hash, }, - binary_sha, - binary_url, + match FixedHash::try_from(binary_sha.into_vec()) { + Ok(hash) => hash, + Err(e) => { + error!(target: LOG_TARGET, "failed to process `binary_sha`: {}", e); + result_tx + .send(UiTransactionSendStatus::Error(format!("Binary checksum error: {}", e))) + .unwrap(); + return; + }, + }, + binary_url.to_string(), fee_per_gram, - pub_validator_key, - sidechain_id_knowledge_proof, + sidechain_id_key.cloned(), ) .await; @@ -542,7 +493,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 == *completed_tx_id { + if sent_tx_id.0 == *completed_tx_id { result_tx.send(UiTransactionSendStatus::TransactionComplete).unwrap(); return; } diff --git a/applications/minotari_console_wallet/src/ui/ui_error.rs b/applications/minotari_console_wallet/src/ui/ui_error.rs index 3059475540..a3d4752955 100644 --- a/applications/minotari_console_wallet/src/ui/ui_error.rs +++ b/applications/minotari_console_wallet/src/ui/ui_error.rs @@ -48,8 +48,6 @@ pub enum UiError { WalletStorageError(#[from] WalletStorageError), #[error("Could not convert string into Public Key")] PublicKeyParseError, - #[error("Could not convert string into Signature")] - SignatureParseError, #[error("Could not convert string into Net Address")] AddressParseError, #[error("Peer did not include an address")] diff --git a/applications/minotari_node/src/grpc/base_node_grpc_server.rs b/applications/minotari_node/src/grpc/base_node_grpc_server.rs index c805868c3a..e6ec4685d3 100644 --- a/applications/minotari_node/src/grpc/base_node_grpc_server.rs +++ b/applications/minotari_node/src/grpc/base_node_grpc_server.rs @@ -1803,13 +1803,13 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer { let mut handler = self.node_service.clone(); let (mut tx, rx) = mpsc::channel(1000); - let sidechain_id = if !request.sidechain_id.is_empty() { + let sidechain_id = if request.sidechain_id.is_empty() { + None + } else { Some( PublicKey::from_canonical_bytes(&request.sidechain_id) .map_err(|e| Status::invalid_argument(format!("Invalid sidechain_id '{}'", e)))?, ) - } else { - None }; task::spawn(async move { diff --git a/base_layer/core/src/chain_storage/blockchain_database.rs b/base_layer/core/src/chain_storage/blockchain_database.rs index 1e50eb2a69..62bd2aadbb 100644 --- a/base_layer/core/src/chain_storage/blockchain_database.rs +++ b/base_layer/core/src/chain_storage/blockchain_database.rs @@ -1416,7 +1416,7 @@ pub fn calculate_validator_node_mr( let mut hash_map = HashMap::new(); for ValidatorNodeRegistrationInfo { public_key: pk, - sidechain_id: sidechain_id, + sidechain_id, shard_key, } in validator_nodes { diff --git a/base_layer/core/src/transactions/key_manager/interface.rs b/base_layer/core/src/transactions/key_manager/interface.rs index ff3082e72a..40c211e27e 100644 --- a/base_layer/core/src/transactions/key_manager/interface.rs +++ b/base_layer/core/src/transactions/key_manager/interface.rs @@ -25,7 +25,10 @@ use digest::consts::U64; use strum_macros::EnumIter; use tari_common_types::types::{ComAndPubSignature, Commitment, PrivateKey, PublicKey, RangeProof, Signature}; use tari_comms::types::CommsDHKE; -use tari_crypto::{hashing::DomainSeparatedHash, ristretto::RistrettoComSig}; +use tari_crypto::{ + hashing::DomainSeparatedHash, + ristretto::{RistrettoComSig, RistrettoSchnorr}, +}; use tari_key_manager::key_manager_service::{KeyId, KeyManagerInterface, KeyManagerServiceError}; use crate::transactions::{ @@ -60,6 +63,7 @@ pub enum TransactionKeyManagerBranch { KernelNonce, ScriptKey, SenderOffset, + CodeTemplateAuthor, } impl TransactionKeyManagerBranch { @@ -75,6 +79,7 @@ impl TransactionKeyManagerBranch { TransactionKeyManagerBranch::KernelNonce => "kernel nonce".to_string(), TransactionKeyManagerBranch::ScriptKey => "script key".to_string(), TransactionKeyManagerBranch::SenderOffset => "sender offset".to_string(), + TransactionKeyManagerBranch::CodeTemplateAuthor => "code_template_author".to_string(), } } } @@ -237,4 +242,17 @@ pub trait TransactionKeyManagerInterface: KeyManagerInterface { pub trait SecretTransactionKeyManagerInterface: TransactionKeyManagerInterface { /// Gets the pedersen commitment for the specified index async fn get_private_key(&self, key_id: &TariKeyId) -> Result; + + async fn sign_raw( + &self, + msg: &[u8], + key_index: &TariKeyId, + nonce_secret: PrivateKey, + ) -> Result { + let secret = self.get_private_key(key_index).await?; + + let sig = RistrettoSchnorr::sign_raw_uniform(&secret, nonce_secret, msg) + .map_err(|e| KeyManagerServiceError::SchnorrSignatureError(e.to_string()))?; + Ok(sig) + } } diff --git a/base_layer/core/src/transactions/transaction_components/side_chain/template_registration.rs b/base_layer/core/src/transactions/transaction_components/side_chain/template_registration.rs index 0d85404d45..f99de30888 100644 --- a/base_layer/core/src/transactions/transaction_components/side_chain/template_registration.rs +++ b/base_layer/core/src/transactions/transaction_components/side_chain/template_registration.rs @@ -54,21 +54,6 @@ impl CodeTemplateRegistration { .finalize() .into() } - - pub fn create_challenge_from_components( - author_public_key: &PublicKey, - public_nonce: &PublicKey, - binary_sha: &MaxSizeBytes<32>, - sidechain_id: Option<&PublicKey>, - ) -> [u8; 64] { - DomainSeparatedConsensusHasher::>::new("template_registration") - .chain(author_public_key) - .chain(public_nonce) - .chain(binary_sha) - .chain(&sidechain_id.as_ref().map(|n| n.to_vec()).unwrap_or(vec![0u8; 32])) - .finalize() - .into() - } } // -------------------------------- TemplateType -------------------------------- // diff --git a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs index 9fc481b2a8..6437cd5efb 100644 --- a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs +++ b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs @@ -169,8 +169,12 @@ fn check_confidential_output_utxo(output: &TransactionOutput) -> Result<(), Vali fn check_template_registration_utxo(output: &TransactionOutput) -> Result<(), ValidationError> { if let Some(temp) = output.features.code_template_registration() { - let challenge = temp.create_challenge(&temp.author_public_key); - if !temp.author_signature.verify(&temp.author_public_key, challenge) { + let challenge = temp.create_challenge(temp.author_signature.get_public_nonce()); + + if !temp + .author_signature + .verify_raw_uniform(&temp.author_public_key, &challenge) + { return Err(ValidationError::TemplateAuthorSignatureNotValid); } diff --git a/base_layer/key_manager/src/key_manager_service/error.rs b/base_layer/key_manager/src/key_manager_service/error.rs index 73f78ae60d..307114d802 100644 --- a/base_layer/key_manager/src/key_manager_service/error.rs +++ b/base_layer/key_manager/src/key_manager_service/error.rs @@ -47,6 +47,8 @@ pub enum KeyManagerServiceError { RangeProofError(String), #[error("Tari Key Manager error: `{0}`")] TariKeyManagerError(#[from] KMError), + #[error("Schnorr signature error: `{0}`")] + SchnorrSignatureError(String), } impl From for KeyManagerServiceError { diff --git a/base_layer/wallet/src/output_manager_service/handle.rs b/base_layer/wallet/src/output_manager_service/handle.rs index 54caae3e11..56347a9013 100644 --- a/base_layer/wallet/src/output_manager_service/handle.rs +++ b/base_layer/wallet/src/output_manager_service/handle.rs @@ -216,7 +216,7 @@ pub enum OutputManagerResponse { RecipientTransactionGenerated(ReceiverTransactionProtocol), OutputConfirmed, PendingTransactionConfirmed, - PayToSelfTransaction((MicroMinotari, Transaction)), + PayToSelfTransaction((MicroMinotari, Transaction, HashOutput)), TransactionToSend(SenderTransactionProtocol), TransactionCancelled, SpentOutputs(Vec), @@ -725,7 +725,7 @@ impl OutputManagerHandle { output_features: OutputFeatures, fee_per_gram: MicroMinotari, lock_height: Option, - ) -> Result<(MicroMinotari, Transaction), OutputManagerError> { + ) -> Result<(MicroMinotari, Transaction, HashOutput), OutputManagerError> { match self .handle .call(OutputManagerRequest::CreatePayToSelfTransaction { diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index 641913cb34..e812d00d49 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -1116,7 +1116,7 @@ where output_features: OutputFeatures, fee_per_gram: MicroMinotari, lock_height: Option, - ) -> Result<(MicroMinotari, Transaction), OutputManagerError> { + ) -> Result<(MicroMinotari, Transaction, HashOutput), OutputManagerError> { let covenant = Covenant::default(); let features_and_scripts_byte_size = self @@ -1163,6 +1163,7 @@ where let (output, sender_offset_key_id) = self.output_to_self(output_features, amount, covenant).await?; + let main_output_hash = output.hash; builder .with_output(output.wallet_output.clone(), sender_offset_key_id.clone()) .await @@ -1217,7 +1218,7 @@ where stp.finalize(&self.resources.key_manager).await?; let tx = stp.into_transaction()?; - Ok((fee, tx)) + Ok((fee, tx, main_output_hash)) } /// Confirm that a transaction has finished being negotiated between parties so the short-term encumberance can be diff --git a/base_layer/wallet/src/transaction_service/error.rs b/base_layer/wallet/src/transaction_service/error.rs index 780430e501..2554814d4e 100644 --- a/base_layer/wallet/src/transaction_service/error.rs +++ b/base_layer/wallet/src/transaction_service/error.rs @@ -191,6 +191,12 @@ pub enum TransactionServiceError { TransactionTooLarge { got: usize, expected: usize }, #[error("Pending Transaction was oversized")] Oversized, + #[error("Error signing sidechain data: `{0}`")] + SidechainSigningError(String), + #[error("Invalid data for a burn transaction: `{0}`")] + InvalidBurnTransaction(String), + #[error("Invalid data for field {field}")] + InvalidDataError { field: String }, } impl From for TransactionServiceError { @@ -277,6 +283,8 @@ pub enum TransactionStorageError { SqliteStorageError(#[from] SqliteStorageError), #[error("Coinbase transactions are not supported in the wallet")] CoinbaseNotSupported, + #[error("Could not sign sidechain data: `{0}`")] + SidechainSigningError(String), } impl From for TransactionStorageError { diff --git a/base_layer/wallet/src/transaction_service/handle.rs b/base_layer/wallet/src/transaction_service/handle.rs index 5f3956f429..856d5dc56c 100644 --- a/base_layer/wallet/src/transaction_service/handle.rs +++ b/base_layer/wallet/src/transaction_service/handle.rs @@ -32,11 +32,10 @@ use tari_common_types::{ burnt_proof::BurntProof, tari_address::TariAddress, transaction::{ImportStatus, TxId}, - types::{PublicKey, Signature}, + types::{FixedHash, PrivateKey, PublicKey, Signature}, }; use tari_comms::types::CommsPublicKey; use tari_core::{ - consensus::{MaxSizeBytes, MaxSizeString}, mempool::FeePerGramStat, proto, transactions::{ @@ -97,32 +96,27 @@ pub enum TransactionServiceRequest { fee_per_gram: MicroMinotari, message: String, claim_public_key: Option, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, }, RegisterValidatorNode { amount: MicroMinotari, validator_node_public_key: CommsPublicKey, validator_node_signature: Signature, validator_node_claim_public_key: CommsPublicKey, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, 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_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, }, SendOneSidedTransaction { destination: TariAddress, @@ -279,6 +273,10 @@ pub enum TransactionServiceResponse { CompletedTransactionValidityChanged, ShaAtomicSwapTransactionSent(Box<(TxId, PublicKey, TransactionOutput)>), FeePerGramStatsPerBlock(FeePerGramStatsResponse), + CodeRegistrationTransactionSent { + tx_id: TxId, + template_address: FixedHash, + }, } #[derive(Clone, Debug, Hash, PartialEq, Eq, Default)] @@ -487,8 +485,7 @@ impl TransactionServiceHandle { validator_node_public_key: PublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -500,8 +497,7 @@ impl TransactionServiceHandle { validator_node_public_key, validator_node_signature, validator_node_claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, selection_criteria, fee_per_gram, message, @@ -515,23 +511,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_id: Option, - sidechain_id_knowledge_proof: Option, - ) -> Result { + sidechain_deployment_key: Option, + ) -> Result<(TxId, FixedHash), TransactionServiceError> { match self .handle .call(TransactionServiceRequest::RegisterCodeTemplate { - author_public_key, - author_signature, template_name, template_version, template_type, @@ -539,12 +530,14 @@ impl TransactionServiceHandle { binary_sha, binary_url, fee_per_gram, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, }) .await?? { - TransactionServiceResponse::TransactionSent(tx_id) => Ok(tx_id), + TransactionServiceResponse::CodeRegistrationTransactionSent { + tx_id, + template_address, + } => Ok((tx_id, template_address)), _ => Err(TransactionServiceError::UnexpectedApiResponse), } } @@ -583,8 +576,7 @@ impl TransactionServiceHandle { fee_per_gram: MicroMinotari, message: String, claim_public_key: Option, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, ) -> Result<(TxId, BurntProof), TransactionServiceError> { match self .handle @@ -594,8 +586,7 @@ impl TransactionServiceHandle { fee_per_gram, message, claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, }) .await?? { diff --git a/base_layer/wallet/src/transaction_service/mod.rs b/base_layer/wallet/src/transaction_service/mod.rs index c02c48630d..9aaf37563f 100644 --- a/base_layer/wallet/src/transaction_service/mod.rs +++ b/base_layer/wallet/src/transaction_service/mod.rs @@ -29,7 +29,7 @@ use tari_core::{ consensus::ConsensusManager, proto::base_node as base_node_proto, transactions::{ - key_manager::TransactionKeyManagerInterface, + key_manager::{SecretTransactionKeyManagerInterface, TransactionKeyManagerInterface}, transaction_protocol::proto::protocol as proto, CryptoFactories, }, @@ -195,7 +195,7 @@ impl ServiceInitializer for TransactionServiceInitia where T: TransactionBackend + 'static, W: WalletBackend + 'static, - TKeyManagerInterface: TransactionKeyManagerInterface, + TKeyManagerInterface: SecretTransactionKeyManagerInterface, { async fn initialize(&mut self, context: ServiceInitializerContext) -> Result<(), ServiceInitializationError> { let (sender, receiver) = reply_channel::unbounded(); diff --git a/base_layer/wallet/src/transaction_service/service.rs b/base_layer/wallet/src/transaction_service/service.rs index e304e42ae1..2b757d679e 100644 --- a/base_layer/wallet/src/transaction_service/service.rs +++ b/base_layer/wallet/src/transaction_service/service.rs @@ -22,7 +22,7 @@ use std::{ collections::{HashMap, HashSet}, - convert::TryInto, + convert::{TryFrom, TryInto}, sync::Arc, time::{Duration, Instant}, }; @@ -37,12 +37,12 @@ use tari_common_types::{ burnt_proof::BurntProof, tari_address::TariAddress, transaction::{ImportStatus, TransactionDirection, TransactionStatus, TxId}, - types::{PrivateKey, PublicKey, Signature}, + types::{FixedHash, HashOutput, PrivateKey, PublicKey, Signature}, }; use tari_comms::types::CommsPublicKey; use tari_comms_dht::outbound::OutboundMessageRequester; use tari_core::{ - consensus::ConsensusManager, + consensus::{ConsensusManager, MaxSizeBytes, MaxSizeString}, covenants::Covenant, mempool::FeePerGramStat, one_sided::{ @@ -53,12 +53,14 @@ use tari_core::{ }, proto::base_node as base_node_proto, transactions::{ - key_manager::TransactionKeyManagerInterface, + key_manager::{SecretTransactionKeyManagerInterface, TransactionKeyManagerBranch}, tari_amount::MicroMinotari, transaction_components::{ + BuildInfo, CodeTemplateRegistration, KernelFeatures, OutputFeatures, + TemplateType, Transaction, TransactionOutput, WalletOutputBuilder, @@ -75,6 +77,8 @@ use tari_core::{ }; use tari_crypto::{ keys::{PublicKey as PKtrait, SecretKey}, + ristretto::RistrettoPublicKey, + signatures::SchnorrSignature, tari_utilities::ByteArray, }; use tari_key_manager::key_manager_service::KeyId; @@ -218,7 +222,7 @@ where TBackend: TransactionBackend + 'static, TWalletBackend: WalletBackend + 'static, TWalletConnectivity: WalletConnectivityInterface, - TKeyManagerInterface: TransactionKeyManagerInterface, + TKeyManagerInterface: SecretTransactionKeyManagerInterface, { pub fn new( config: TransactionServiceConfig, @@ -633,7 +637,7 @@ where transaction_broadcast_join_handles, ) .await - .map(TransactionServiceResponse::TransactionSent), + .map(|(tx_id, _)| TransactionServiceResponse::TransactionSent(tx_id)), TransactionServiceRequest::SendOneSidedToStealthAddressTransaction { destination, amount, @@ -652,15 +656,14 @@ where transaction_broadcast_join_handles, ) .await - .map(TransactionServiceResponse::TransactionSent), + .map(|(tx_id, _)| TransactionServiceResponse::TransactionSent(tx_id)), TransactionServiceRequest::BurnTari { amount, selection_criteria, fee_per_gram, message, claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, } => self .burn_tari( amount, @@ -668,8 +671,7 @@ where fee_per_gram, message, claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, transaction_broadcast_join_handles, ) .await @@ -682,8 +684,7 @@ where validator_node_public_key, validator_node_signature, validator_node_claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, selection_criteria, fee_per_gram, message, @@ -694,8 +695,7 @@ where validator_node_public_key, validator_node_signature, validator_node_claim_public_key, - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_deployment_key, selection_criteria, fee_per_gram, message, @@ -707,8 +707,6 @@ where return Ok(()); }, TransactionServiceRequest::RegisterCodeTemplate { - author_public_key, - author_signature, template_name, template_version, template_type, @@ -716,32 +714,27 @@ where binary_sha, binary_url, fee_per_gram, - sidechain_id, - sidechain_id_knowledge_proof, + 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_id, - sidechain_id_knowledge_proof, - }, - 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(()); + sidechain_deployment_key, + 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, @@ -1001,7 +994,7 @@ where JoinHandle>>, >, reply_channel: oneshot::Sender>, - ) -> Result<(), TransactionServiceError> { + ) -> Result<(TxId, Option), TransactionServiceError> { let tx_id = TxId::new_random(); if destination.network() != self.resources.wallet_identity.network { let _result = reply_channel @@ -1020,7 +1013,7 @@ where "Received transaction with spend-to-self transaction" ); - let (fee, transaction) = self + let (fee, transaction, main_output) = self .resources .output_manager_service .create_pay_to_self_transaction(tx_id, amount, selection_criteria, output_features, fee_per_gram, None) @@ -1057,7 +1050,7 @@ where e }); - return Ok(()); + return Ok((tx_id, Some(main_output))); } let (tx_reply_sender, tx_reply_receiver) = mpsc::channel(100); @@ -1083,7 +1076,7 @@ where let join_handle = tokio::spawn(protocol.execute()); join_handles.push(join_handle); - Ok(()) + Ok((tx_id, None)) } /// broadcasts a SHA-XTR atomic swap transaction @@ -1320,7 +1313,7 @@ where JoinHandle>>, >, script: TariScript, - ) -> Result { + ) -> Result<(TxId, HashOutput), TransactionServiceError> { let tx_id = TxId::new_random(); // Prepare sender part of the transaction @@ -1439,6 +1432,7 @@ where let recipient_reply = rtp.get_signed_data()?.clone(); + let main_output_hash = recipient_reply.output.hash(); // Start finalizing stp.add_presigned_recipient_info(recipient_reply) .map_err(|e| TransactionServiceProtocolError::new(tx_id, e.into()))?; @@ -1489,7 +1483,7 @@ where ) .await?; - Ok(tx_id) + Ok((tx_id, main_output_hash)) } /// Sends a one side payment transaction to a recipient @@ -1508,7 +1502,7 @@ where transaction_broadcast_join_handles: &mut FuturesUnordered< JoinHandle>>, >, - ) -> Result { + ) -> Result<(TxId, HashOutput), TransactionServiceError> { if destination.network() != self.resources.wallet_identity.network { return Err(TransactionServiceError::InvalidNetwork); } @@ -1546,14 +1540,28 @@ where fee_per_gram: MicroMinotari, message: String, claim_public_key: Option, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, transaction_broadcast_join_handles: &mut FuturesUnordered< JoinHandle>>, >, ) -> Result<(TxId, BurntProof), TransactionServiceError> { let tx_id = TxId::new_random(); trace!(target: LOG_TARGET, "Burning transaction start - TxId: {}", tx_id); + if claim_public_key.is_none() && sidechain_deployment_key.is_some() { + return Err(TransactionServiceError::InvalidBurnTransaction( + "A sidechain deployment key was provided without a claim public key".to_string(), + )); + } + let (sidechain_id, sidechain_id_knowledge_proof) = match sidechain_deployment_key { + Some(key) => { + let sidechain_id = PublicKey::from_secret_key(&key); + let sidechain_id_knowledge_proof = + SchnorrSignature::sign(&key, claim_public_key.as_ref().unwrap().to_vec(), &mut OsRng) + .map_err(|e| TransactionServiceError::InvalidBurnTransaction(format!("Error: {:?}", e)))?; + (Some(sidechain_id), Some(sidechain_id_knowledge_proof)) + }, + None => (None, None), + }; let output_features = claim_public_key .as_ref() .cloned() @@ -1769,8 +1777,7 @@ where validator_node_public_key: CommsPublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, + sidechain_deployment_key: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -1782,6 +1789,16 @@ where >, reply_channel: oneshot::Sender>, ) -> Result<(), TransactionServiceError> { + let (sidechain_id, sidechain_id_knowledge_proof) = match sidechain_deployment_key { + Some(k) => { + let sidechain_id = PublicKey::from_secret_key(&k); + let sidechain_id_knowledge_proof = + SchnorrSignature::sign(&k, validator_node_public_key.to_vec(), &mut OsRng) + .map_err(|e| TransactionServiceError::SidechainSigningError(e.to_string()))?; + (Some(sidechain_id), Some(sidechain_id_knowledge_proof)) + }, + None => (None, None), + }; let output_features = OutputFeatures::for_validator_node_registration( validator_node_public_key, validator_node_signature, @@ -1801,36 +1818,94 @@ where transaction_broadcast_join_handles, reply_channel, ) - .await + .await?; + Ok(()) } pub async fn register_code_template( &mut self, fee_per_gram: MicroMinotari, - template_registration: CodeTemplateRegistration, + template_name: String, + template_version: u16, + template_type: TemplateType, + build_info: BuildInfo, + binary_sha: FixedHash, + binary_url: String, + sidechain_deployment_key: Option, selection_criteria: UtxoSelectionCriteria, message: String, - join_handles: &mut FuturesUnordered< - JoinHandle>>, - >, + transaction_broadcast_join_handles: &mut FuturesUnordered< JoinHandle>>, >, - reply_channel: oneshot::Sender>, - ) -> Result<(), TransactionServiceError> { - self.send_transaction( - self.resources.wallet_identity.address.clone(), + ) -> Result<(TxId, HashOutput), TransactionServiceError> { + let (author_pub_id, author_pub_key) = self + .resources + .transaction_key_manager_service + .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_pub_key.to_vec(), &mut OsRng) + .map_err(|e| TransactionServiceError::SidechainSigningError(e.to_string()))?, + ), + ), + None => (None, None), + }; + + let mut template_registration = CodeTemplateRegistration { + author_public_key: author_pub_key.clone(), + author_signature: Signature::default(), + template_name: template_name + .try_into() + .map_err(|_| TransactionServiceError::InvalidDataError { + field: "template_name".to_string(), + })?, + template_version, + template_type, + build_info, + binary_sha: MaxSizeBytes::try_from(binary_sha.as_slice().to_vec()).map_err(|_| { + TransactionServiceError::InvalidDataError { + field: "binary_sha".to_string(), + } + })?, + binary_url: MaxSizeString::try_from(binary_url).map_err(|_| TransactionServiceError::InvalidDataError { + field: "binary_url".to_string(), + })?, + sidechain_id, + sidechain_id_knowledge_proof, + }; + + let challenge = template_registration.create_challenge(&nonce_pub); + let author_sig = self + .resources + .transaction_key_manager_service + .sign_raw(&challenge, &author_pub_id, nonce_secret) + .await + .map_err(|e| TransactionServiceError::SidechainSigningError(e.to_string()))?; + + template_registration.author_signature = author_sig; + + let output_features = OutputFeatures::for_template_registration(template_registration); + let tx_id = TxId::new_random(); + let (fee, transaction, main_output_hash) = self + .resources + .output_manager_service + .create_pay_to_self_transaction(tx_id, 0.into(), selection_criteria, output_features, fee_per_gram, None) + .await?; + self.submit_transaction_to_self( + transaction_broadcast_join_handles, + tx_id, + transaction, + fee, 0.into(), - selection_criteria, - OutputFeatures::for_template_registration(template_registration), - fee_per_gram, message, - TransactionMetadata::default(), - join_handles, - transaction_broadcast_join_handles, - reply_channel, ) - .await + .await?; + Ok((tx_id, main_output_hash)) } /// Sends a one side payment transaction to a recipient @@ -1849,7 +1924,7 @@ where transaction_broadcast_join_handles: &mut FuturesUnordered< JoinHandle>>, >, - ) -> Result { + ) -> Result<(TxId, HashOutput), TransactionServiceError> { if destination.network() != self.resources.wallet_identity.network { return Err(TransactionServiceError::InvalidNetwork); } diff --git a/base_layer/wallet/tests/transaction_service_tests/service.rs b/base_layer/wallet/tests/transaction_service_tests/service.rs index 052d2c09fb..4e745860c6 100644 --- a/base_layer/wallet/tests/transaction_service_tests/service.rs +++ b/base_layer/wallet/tests/transaction_service_tests/service.rs @@ -1394,16 +1394,12 @@ async fn large_coin_split_transaction() { #[tokio::test] async fn single_transaction_burn_tari() { - single_transaction_burn_tari_inner(None, None).await; - let (sk, pk) = PublicKey::random_keypair(&mut OsRng); - let sig = Signature::sign(&sk, [], &mut OsRng).unwrap(); - single_transaction_burn_tari_inner(Some(pk.clone()), Some(sig)).await; + single_transaction_burn_tari_inner(None).await; + let (sk, _pk) = PublicKey::random_keypair(&mut OsRng); + single_transaction_burn_tari_inner(Some(sk.clone())).await; } -async fn single_transaction_burn_tari_inner( - sidechain_id: Option, - sidechain_id_knowledge_proof: Option, -) { +async fn single_transaction_burn_tari_inner(sidechain_key: Option) { // let _ = env_logger::builder().is_test(true).try_init(); // Need `$env:RUST_LOG = "trace"` for this to work let network = Network::LocalNet; let consensus_manager = ConsensusManager::builder(network).build().unwrap(); @@ -1471,8 +1467,7 @@ async fn single_transaction_burn_tari_inner( 20.into(), message.clone(), Some(claim_public_key.clone()), - sidechain_id, - sidechain_id_knowledge_proof, + sidechain_key, ) .await .expect("Alice sending burn tx"); diff --git a/ci_all.bat b/ci_all.bat new file mode 100644 index 0000000000..777c6070e0 --- /dev/null +++ b/ci_all.bat @@ -0,0 +1,5 @@ +cargo +nightly ci-fmt +cargo machete +cargo ci-check +cargo ci-test +cargo ci-cucumber \ No newline at end of file diff --git a/hash_domains/Cargo.toml b/hash_domains/Cargo.toml deleted file mode 100644 index 0439960998..0000000000 --- a/hash_domains/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "tari_hash_domains" -version = "1.0.0-dan.5" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -tari_crypto = "0.20.0" diff --git a/hash_domains/src/lib.rs b/hash_domains/src/lib.rs deleted file mode 100644 index a88f9b4519..0000000000 --- a/hash_domains/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2023. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -use tari_crypto::hash_domain; - -// These are the hash domains that are also used in tari-dan. - -hash_domain!(ConfidentialOutputHashDomain, "com.tari.dan.confidential_output", 1); -hash_domain!(TariEngineHashDomain, "com.tari.dan.engine", 0); - -// Hash domain used to derive the final AEAD encryption key for encrypted data in UTXOs -hash_domain!( - TransactionSecureNonceKdfDomain, - "com.tari.base_layer.core.transactions.secure_nonce_kdf", - 0 -); -hash_domain!( - ValidatorNodeBmtHashDomain, - "com.tari.base_layer.core.validator_node_mmr", - 1 -); -hash_domain!( - WalletOutputEncryptionKeysDomain, - "com.tari.base_layer.wallet.output_encryption_keys", - 1 -); diff --git a/integration_tests/tests/steps/wallet_steps.rs b/integration_tests/tests/steps/wallet_steps.rs index cfc62087da..e3fce3a8a1 100644 --- a/integration_tests/tests/steps/wallet_steps.rs +++ b/integration_tests/tests/steps/wallet_steps.rs @@ -2768,8 +2768,7 @@ async fn burn_transaction(world: &mut TariWorld, amount: u64, wallet: String, fe fee_per_gram: fee, message: "Burning some tari".to_string(), claim_public_key: identity.public_key, - sidechain_id: vec![], - sidechain_id_knowledge_proof: None, + sidechain_deployment_key: vec![], }; let result = client.create_burn_transaction(req).await.unwrap();