diff --git a/applications/minotari_app_grpc/proto/types.proto b/applications/minotari_app_grpc/proto/types.proto index b1d414cbd3e..d613d437c3f 100644 --- a/applications/minotari_app_grpc/proto/types.proto +++ b/applications/minotari_app_grpc/proto/types.proto @@ -1,32 +1,38 @@ // Copyright 2020. The Tari Project // -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: +// 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. +// 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. +// 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. +// 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. +// 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. syntax = "proto3"; package tari.rpc; /// An unsigned range interface to more accurately represent Rust native Range's message Range { - uint64 min = 1; - uint64 max = 2; + uint64 min = 1; + uint64 max = 2; } /// An Empty placeholder for endpoints without request parameters @@ -34,106 +40,105 @@ message Empty {} /// Define an interface for block height message BlockHeight { - uint64 block_height = 1; + uint64 block_height = 1; } -// Define the explicit Signature implementation for the Minotari base layer. A different signature scheme can be -// employed by redefining this type. +// Define the explicit Signature implementation for the Minotari base layer. A +// different signature scheme can be employed by redefining this type. message Signature { - bytes public_nonce = 1; - bytes signature = 2; + bytes public_nonce = 1; + bytes signature = 2; } -// Define the explicit ComAndPubSignature implementation for the Minotari base layer. A different signature scheme can be -// employed by redefining this type. +// Define the explicit ComAndPubSignature implementation for the Minotari base +// layer. A different signature scheme can be employed by redefining this type. message ComAndPubSignature { - bytes ephemeral_commitment = 1; - bytes ephemeral_pubkey = 2; - bytes u_a = 3; - bytes u_x = 4; - bytes u_y = 5; + bytes ephemeral_commitment = 1; + bytes ephemeral_pubkey = 2; + bytes u_a = 3; + bytes u_x = 4; + bytes u_y = 5; } -// Define the explicit CommitmentSignature implementation for the Minotari base layer. A different signature scheme can be -// employed by redefining this type +// Define the explicit CommitmentSignature implementation for the Minotari base +// layer. A different signature scheme can be employed by redefining this type message CommitmentSignature { - bytes public_nonce = 1; - bytes u = 2; - bytes v = 3; + bytes public_nonce = 1; + bytes u = 2; + bytes v = 3; } /// PoW Algorithm constants message PowAlgorithmConstants { - uint64 min_difficulty = 2; - uint64 max_difficulty = 3; - uint64 target_time = 4; + uint64 min_difficulty = 2; + uint64 max_difficulty = 3; + uint64 target_time = 4; } /// Weight params message WeightParams { - uint64 kernel_weight = 1; - uint64 input_weight = 2; - uint64 output_weight = 3; - uint64 features_and_scripts_bytes_per_gram = 4; + uint64 kernel_weight = 1; + uint64 input_weight = 2; + uint64 output_weight = 3; + uint64 features_and_scripts_bytes_per_gram = 4; } /// Output version message OutputsVersion { - Range outputs = 1; - Range features = 2; + Range outputs = 1; + Range features = 2; } /// Output types enum OutputType { - STANDARD = 0; - COINBASE = 1; - BURN = 2; - VALIDATOR_NODE_REGISTRATION = 3; - CODE_TEMPLATE_REGISTRATION = 4; + STANDARD = 0; + COINBASE = 1; + BURN = 2; + VALIDATOR_NODE_REGISTRATION = 3; + CODE_TEMPLATE_REGISTRATION = 4; } /// Range proof types enum RangeProofType { - BULLETPROOF_PLUS = 0; - REVEALED_VALUE = 1; + BULLETPROOF_PLUS = 0; + REVEALED_VALUE = 1; } /// Range proof message RangeProof { - bytes proof_bytes = 1; + bytes proof_bytes = 1; } /// Consensus Constants response message ConsensusConstants { - uint64 coinbase_min_maturity = 1; - uint32 blockchain_version = 2; - uint64 future_time_limit = 3; - uint64 difficulty_block_window = 5; - uint64 max_block_transaction_weight = 7; - uint64 pow_algo_count = 8; - uint64 median_timestamp_count = 9; - uint64 emission_initial = 10; - repeated uint64 emission_decay = 11; - uint64 emission_tail = 12; - uint64 min_sha3x_pow_difficulty = 13; - uint64 block_weight_inputs = 14; - uint64 block_weight_outputs = 15; - uint64 block_weight_kernels = 16; - uint64 faucet_value = 17; - uint64 max_script_byte_size = 18; - uint64 validator_node_validity_period = 19; - uint64 effective_from_height = 20; - Range valid_blockchain_version_range = 21; - uint64 max_randomx_seed_height = 22; - map proof_of_work = 23; - WeightParams transaction_weight = 24; - Range input_version_range = 26; - OutputsVersion output_version_range = 27; - Range kernel_version_range = 28; - repeated OutputType permitted_output_types = 29; - uint64 epoch_length = 30; - uint64 validator_node_registration_min_deposit_amount = 31; - uint64 validator_node_registration_min_lock_height = 32; - uint64 validator_node_registration_shuffle_interval_epoch = 33; - repeated RangeProofType permitted_range_proof_types = 34; + uint64 coinbase_min_maturity = 1; + uint32 blockchain_version = 2; + uint64 future_time_limit = 3; + uint64 difficulty_block_window = 5; + uint64 max_block_transaction_weight = 7; + uint64 pow_algo_count = 8; + uint64 median_timestamp_count = 9; + uint64 emission_initial = 10; + repeated uint64 emission_decay = 11; + uint64 emission_tail = 12; + uint64 min_sha3x_pow_difficulty = 13; + uint64 block_weight_inputs = 14; + uint64 block_weight_outputs = 15; + uint64 block_weight_kernels = 16; + uint64 faucet_value = 17; + uint64 max_script_byte_size = 18; + uint64 validator_node_validity_period = 19; + uint64 effective_from_height = 20; + Range valid_blockchain_version_range = 21; + uint64 max_randomx_seed_height = 22; + map proof_of_work = 23; + WeightParams transaction_weight = 24; + Range input_version_range = 26; + OutputsVersion output_version_range = 27; + Range kernel_version_range = 28; + repeated OutputType permitted_output_types = 29; + uint64 epoch_length = 30; + uint64 validator_node_registration_min_deposit_amount = 31; + uint64 validator_node_registration_shuffle_interval_epoch = 33; + repeated RangeProofType permitted_range_proof_types = 34; } diff --git a/applications/minotari_app_grpc/proto/wallet.proto b/applications/minotari_app_grpc/proto/wallet.proto index 6c5435b46a0..e2a71019469 100644 --- a/applications/minotari_app_grpc/proto/wallet.proto +++ b/applications/minotari_app_grpc/proto/wallet.proto @@ -1,24 +1,30 @@ // Copyright 2020. The Tari Project // -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: +// 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. +// 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. +// 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. +// 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. +// 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. syntax = "proto3"; package tari.rpc; @@ -31,95 +37,104 @@ 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); - // This returns a coinbase transaction - rpc GetCoinbase (GetCoinbaseRequest) returns (GetCoinbaseResponse); - // 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); - // 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); + // This returns a coinbase transaction + rpc GetCoinbase(GetCoinbaseRequest) returns (GetCoinbaseResponse); + // 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); + // 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; +message CreateBurnTransactionRequest { + uint64 amount = 1; + uint64 fee_per_gram = 2; + string message = 3; + bytes claim_public_key = 4; } - 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 { @@ -127,225 +142,228 @@ 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; +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; } 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; +message ClaimShaAtomicSwapRequest { + 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; +message ClaimHtlcRefundRequest { + 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 not found by the wallet its in transaction database - TRANSACTION_STATUS_NOT_FOUND = 7; - // The transaction was rejected by the mempool - TRANSACTION_STATUS_REJECTED = 8; - // This is faux transaction mainly for one-sided transaction outputs or wallet recovery outputs have been found - TRANSACTION_STATUS_FAUX_UNCONFIRMED = 9; - // All Imported and FauxUnconfirmed transactions will end up with this status when the outputs have been confirmed - TRANSACTION_STATUS_FAUX_CONFIRMED = 10; - // This transaction is still being queued for sending - TRANSACTION_STATUS_QUEUED = 11; -} - -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 not found by the wallet its in transaction database + TRANSACTION_STATUS_NOT_FOUND = 7; + // The transaction was rejected by the mempool + TRANSACTION_STATUS_REJECTED = 8; + // This is faux transaction mainly for one-sided transaction outputs or wallet + // recovery outputs have been found + TRANSACTION_STATUS_FAUX_UNCONFIRMED = 9; + // All Imported and FauxUnconfirmed transactions will end up with this status + // when the outputs have been confirmed + TRANSACTION_STATUS_FAUX_CONFIRMED = 10; + // This transaction is still being queued for sending + TRANSACTION_STATUS_QUEUED = 11; +} + +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 GetCoinbaseRequest { - uint64 reward = 1; - uint64 fee = 2; - uint64 height = 3; - bytes extra = 4; + uint64 reward = 1; + uint64 fee = 2; + uint64 height = 3; + bytes extra = 4; } message GetCoinbaseResponse { - Transaction transaction = 1; + Transaction transaction = 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; + TemplateRegistration template_registration = 1; + uint64 fee_per_gram = 2; } 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{} +message RevalidateRequest {} -message RevalidateResponse{} +message RevalidateResponse {} message SetBaseNodeRequest { - string public_key_hex = 1; - string net_address = 2; + string public_key_hex = 1; + string net_address = 2; } -message SetBaseNodeResponse{} +message SetBaseNodeResponse {} -message GetConnectivityRequest{} +message GetConnectivityRequest {} -message CheckConnectivityResponse{ - enum OnlineStatus { - Connecting = 0; - Online = 1; - Offline = 2; - } - OnlineStatus status = 1; +message CheckConnectivityResponse { + enum OnlineStatus { + Connecting = 0; + Online = 1; + Offline = 2; + } + OnlineStatus status = 1; } -message TransactionEventRequest{ - -} +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; - bool is_coinbase = 9; + 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; + bool is_coinbase = 9; } 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 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; + uint64 validator_maturity = 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_app_grpc/src/conversions/consensus_constants.rs b/applications/minotari_app_grpc/src/conversions/consensus_constants.rs index 0ff66a9728f..50f00bee431 100644 --- a/applications/minotari_app_grpc/src/conversions/consensus_constants.rs +++ b/applications/minotari_app_grpc/src/conversions/consensus_constants.rs @@ -127,7 +127,6 @@ impl From for grpc::ConsensusConstants { validator_node_registration_min_deposit_amount: cc .validator_node_registration_min_deposit_amount() .as_u64(), - validator_node_registration_min_lock_height: cc.validator_node_registration_min_lock_height(), validator_node_registration_shuffle_interval_epoch: cc .validator_node_registration_shuffle_interval() .as_u64(), diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index 8a4a3fc027e..b478a0a39ca 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -202,6 +202,7 @@ pub async fn register_validator_node( validator_node_public_key: PublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, + validator_maturity: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -212,6 +213,7 @@ pub async fn register_validator_node( validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity, selection_criteria, fee_per_gram, message, @@ -973,6 +975,7 @@ pub async fn command_runner( RistrettoSecretKey::from_vec(&args.validator_node_signature[0])?, ), args.validator_node_claim_public_key.into(), + args.validator_maturity, UtxoSelectionCriteria::default(), config.fee_per_gram * uT, args.message, diff --git a/applications/minotari_console_wallet/src/cli.rs b/applications/minotari_console_wallet/src/cli.rs index 943def56499..7dd7a4740ea 100644 --- a/applications/minotari_console_wallet/src/cli.rs +++ b/applications/minotari_console_wallet/src/cli.rs @@ -288,6 +288,7 @@ 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 validator_maturity: Option, #[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 97072caf683..0fda7c288bf 100644 --- a/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -1011,6 +1011,11 @@ impl wallet_server::Wallet for WalletGrpcServer { .map_err(|_| Status::invalid_argument("Validator node signature is malformed!"))?; 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 validator_maturity = if request.validator_maturity > 0 { + Some(request.validator_maturity) + } else { + None + }; let constants = self.get_consensus_constants().map_err(|e| { error!(target: LOG_TARGET, "Failed to get consensus constants: {}", e); @@ -1023,6 +1028,7 @@ impl wallet_server::Wallet for WalletGrpcServer { validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity, UtxoSelectionCriteria::default(), request.fee_per_gram.into(), request.message, diff --git a/base_layer/core/src/chain_storage/tests/blockchain_database.rs b/base_layer/core/src/chain_storage/tests/blockchain_database.rs index 5aab7f7dc1a..c77f2ad5b65 100644 --- a/base_layer/core/src/chain_storage/tests/blockchain_database.rs +++ b/base_layer/core/src/chain_storage/tests/blockchain_database.rs @@ -602,6 +602,7 @@ mod validator_node_merkle_root { public_key.clone(), signature.signature().clone(), public_key.clone(), + 10000, ); let (tx, _outputs) = schema_to_transaction( &[txn_schema!( diff --git a/base_layer/core/src/consensus/consensus_constants.rs b/base_layer/core/src/consensus/consensus_constants.rs index 7678573f109..3cb14e51de6 100644 --- a/base_layer/core/src/consensus/consensus_constants.rs +++ b/base_layer/core/src/consensus/consensus_constants.rs @@ -111,8 +111,6 @@ pub struct ConsensusConstants { vn_validity_period_epochs: VnEpoch, /// The min amount of micro Minotari to deposit for a registration transaction to be allowed onto the blockchain vn_registration_min_deposit_amount: MicroMinotari, - /// The period that the registration funds are required to be locked up. - vn_registration_lock_height: u64, /// The period after which the VNs will be reshuffled. vn_registration_shuffle_interval: VnEpoch, } @@ -326,8 +324,11 @@ impl ConsensusConstants { self.vn_registration_min_deposit_amount } - pub fn validator_node_registration_min_lock_height(&self) -> u64 { - self.vn_registration_lock_height + pub fn validator_node_registration_min_lock_height(&self, height: u64) -> u64 { + // This calculates the height of the block in which the VN is not valid anymore. + self.epoch_to_block_height(VnEpoch( + self.block_height_to_epoch(height).as_u64() + 1 + self.vn_validity_period_epochs.as_u64(), + )) } /// Returns the current epoch from the given height @@ -383,8 +384,7 @@ impl ConsensusConstants { max_covenant_length: 100, vn_epoch_length: 10, vn_validity_period_epochs: VnEpoch(100), - vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, + vn_registration_min_deposit_amount: MicroMinotari(1000000), vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; @@ -447,7 +447,6 @@ impl ConsensusConstants { vn_epoch_length: 10, vn_validity_period_epochs: VnEpoch(3), vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; @@ -507,7 +506,6 @@ impl ConsensusConstants { vn_epoch_length: 60, vn_validity_period_epochs: VnEpoch(100), vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; @@ -561,7 +559,6 @@ impl ConsensusConstants { vn_epoch_length: 60, vn_validity_period_epochs: VnEpoch(100), vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; @@ -609,7 +606,6 @@ impl ConsensusConstants { vn_epoch_length: 60, vn_validity_period_epochs: VnEpoch(100), vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; @@ -659,7 +655,6 @@ impl ConsensusConstants { vn_epoch_length: 60, vn_validity_period_epochs: VnEpoch(100), vn_registration_min_deposit_amount: MicroMinotari(0), - vn_registration_lock_height: 0, vn_registration_shuffle_interval: VnEpoch(100), coinbase_output_features_extra_max_length: 64, }]; 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 eab4589a3c3..1fcdee7fe2e 100644 --- a/base_layer/core/src/transactions/transaction_components/output_features.rs +++ b/base_layer/core/src/transactions/transaction_components/output_features.rs @@ -145,12 +145,14 @@ impl OutputFeatures { public_key: PublicKey, signature: Signature, claim_public_key: PublicKey, + maturity: u64, ) -> OutputFeatures { OutputFeatures { output_type: OutputType::ValidatorNodeRegistration, sidechain_feature: Some(SideChainFeature::ValidatorNodeRegistration( ValidatorNodeRegistration::new(ValidatorNodeSignature::new(public_key, signature), claim_public_key), )), + maturity, ..Default::default() } } diff --git a/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs b/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs index 67c0824c200..77d2bc14e44 100644 --- a/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs +++ b/base_layer/core/src/validation/aggregate_body/aggregate_body_chain_validator.rs @@ -60,7 +60,7 @@ impl AggregateBodyChainLinkedValidator { ) -> Result { let constants = self.consensus_manager.consensus_constants(height); - self.validate_consensus(body, db, constants)?; + self.validate_consensus(body, db, constants, height)?; let body = self.validate_input_and_maturity(body, db, constants, height)?; Ok(body) @@ -71,11 +71,12 @@ impl AggregateBodyChainLinkedValidator { body: &AggregateBody, db: &B, constants: &ConsensusConstants, + height: u64, ) -> Result<(), ValidationError> { validate_excess_sig_not_in_db(body, db)?; for output in body.outputs() { - check_validator_node_registration_utxo(constants, output)?; + check_validator_node_registration_utxo(constants, output, height)?; } Ok(()) @@ -96,7 +97,7 @@ impl AggregateBodyChainLinkedValidator { validate_input_maturity(&body, height)?; check_inputs_are_utxos(db, &body)?; - check_outputs(db, constants, &body)?; + check_outputs(db, constants, &body, height)?; verify_no_duplicated_inputs_outputs(&body)?; check_total_burned(&body)?; verify_timelocks(&body, height)?; @@ -169,6 +170,7 @@ fn validate_excess_sig_not_in_db(body: &AggregateBody, db: fn check_validator_node_registration_utxo( consensus_constants: &ConsensusConstants, utxo: &TransactionOutput, + height: u64, ) -> Result<(), ValidationError> { if let Some(reg) = utxo.features.validator_node_registration() { if utxo.minimum_value_promise < consensus_constants.validator_node_registration_min_deposit_amount() { @@ -177,9 +179,9 @@ fn check_validator_node_registration_utxo( actual: utxo.minimum_value_promise, }); } - if utxo.features.maturity < consensus_constants.validator_node_registration_min_lock_height() { + if utxo.features.maturity < consensus_constants.validator_node_registration_min_lock_height(height) { return Err(ValidationError::ValidatorNodeRegistrationMinLockHeight { - min: consensus_constants.validator_node_registration_min_lock_height(), + min: consensus_constants.validator_node_registration_min_lock_height(height), actual: utxo.features.maturity, }); } @@ -234,12 +236,13 @@ pub fn check_outputs( db: &B, constants: &ConsensusConstants, body: &AggregateBody, + height: u64, ) -> Result<(), ValidationError> { let max_script_size = constants.max_script_byte_size(); for output in body.outputs() { check_tari_script_byte_size(&output.script, max_script_size)?; check_not_duplicate_txo(db, output)?; - check_validator_node_registration_utxo(constants, output)?; + check_validator_node_registration_utxo(constants, output, height)?; } Ok(()) } 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 4b4a899eadd..14bdeb3fdc0 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 @@ -115,7 +115,7 @@ impl AggregateBodyInternalConsistencyValidator { check_script_size(output, constants.max_script_byte_size())?; check_covenant_length(&output.covenant, constants.max_covenant_length())?; check_permitted_range_proof_types(constants, output)?; - check_validator_node_registration_utxo(constants, output)?; + check_validator_node_registration_utxo(constants, output, height)?; } check_weight(body, height, constants)?; @@ -378,6 +378,7 @@ fn check_total_burned(body: &AggregateBody) -> Result<(), ValidationError> { fn check_validator_node_registration_utxo( consensus_constants: &ConsensusConstants, utxo: &TransactionOutput, + height: u64, ) -> Result<(), ValidationError> { if let Some(reg) = utxo.features.validator_node_registration() { if utxo.minimum_value_promise < consensus_constants.validator_node_registration_min_deposit_amount() { @@ -386,9 +387,9 @@ fn check_validator_node_registration_utxo( actual: utxo.minimum_value_promise, }); } - if utxo.features.maturity < consensus_constants.validator_node_registration_min_lock_height() { + if utxo.features.maturity < consensus_constants.validator_node_registration_min_lock_height(height) { return Err(ValidationError::ValidatorNodeRegistrationMinLockHeight { - min: consensus_constants.validator_node_registration_min_lock_height(), + min: consensus_constants.validator_node_registration_min_lock_height(height), actual: utxo.features.maturity, }); } diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index 497c9016924..c409edf8fbf 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -1949,7 +1949,11 @@ where .key_manager .encrypt_data_for_recovery(&spending_key_id, None, amount.as_u64()) .await?; - let minimum_value_promise = MicroMinotari::zero(); + let minimum_value_promise = if output_features.validator_node_registration().is_none() { + MicroMinotari::zero() + } else { + amount + }; let metadata_message = TransactionOutput::metadata_signature_message_from_parts( &TransactionOutputVersion::get_current_version(), &script, diff --git a/base_layer/wallet/src/transaction_service/handle.rs b/base_layer/wallet/src/transaction_service/handle.rs index fa907914781..68109d5f76d 100644 --- a/base_layer/wallet/src/transaction_service/handle.rs +++ b/base_layer/wallet/src/transaction_service/handle.rs @@ -102,6 +102,7 @@ pub enum TransactionServiceRequest { validator_node_public_key: CommsPublicKey, validator_node_signature: Signature, validator_node_claim_public_key: CommsPublicKey, + validator_maturity: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -499,6 +500,7 @@ impl TransactionServiceHandle { validator_node_public_key: PublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, + validator_maturity: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -510,6 +512,7 @@ impl TransactionServiceHandle { validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity, selection_criteria, fee_per_gram, message, diff --git a/base_layer/wallet/src/transaction_service/service.rs b/base_layer/wallet/src/transaction_service/service.rs index 45d13d145a1..33e067ac289 100644 --- a/base_layer/wallet/src/transaction_service/service.rs +++ b/base_layer/wallet/src/transaction_service/service.rs @@ -673,6 +673,7 @@ where validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity, selection_criteria, fee_per_gram, message, @@ -683,6 +684,7 @@ where validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity, selection_criteria, fee_per_gram, message, @@ -1736,6 +1738,7 @@ where validator_node_public_key: CommsPublicKey, validator_node_signature: Signature, validator_node_claim_public_key: PublicKey, + validator_maturity: Option, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, message: String, @@ -1751,6 +1754,12 @@ where validator_node_public_key, validator_node_signature, validator_node_claim_public_key, + validator_maturity.unwrap_or_else(|| { + let next_height = self.last_seen_tip_height.unwrap_or(0) + 1; + self.consensus_manager + .consensus_constants(next_height) + .validator_node_registration_min_lock_height(next_height) + }), ); self.send_transaction( self.resources.wallet_identity.address.clone(), diff --git a/common/config/presets/c_base_node.toml b/common/config/presets/c_base_node.toml index 9c8a3070769..535dbdc6c0a 100644 --- a/common/config/presets/c_base_node.toml +++ b/common/config/presets/c_base_node.toml @@ -38,13 +38,13 @@ identity_file = "config/base_node_id_nextnet.json" # Uncomment all gRPC server methods that should be denied default (only active when `grpc_enabled = true`) grpc_server_deny_methods = [ - "get_version", - "check_for_updates", - "get_sync_info", - "get_sync_progress", - "get_tip_info", - "identify", - "get_network_status", + #"get_version", + #"check_for_updates", + #"get_sync_info", + #"get_sync_progress", + #"get_tip_info", + #"identify", + #"get_network_status", #"list_headers" #"get_header_by_hash" #"get_blocks"