From 407839fa2afa8dd400cdf9528311fb582d5958bd Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Fri, 17 May 2024 13:35:02 +0200 Subject: [PATCH] add default proto files --- .../minotari_app_grpc/proto/base_node.proto | 517 ++++++++++++++++++ .../minotari_app_grpc/proto/block.proto | 137 +++++ .../minotari_app_grpc/proto/network.proto | 97 ++++ .../proto/sidechain_types.proto | 77 +++ .../minotari_app_grpc/proto/transaction.proto | 182 ++++++ .../minotari_app_grpc/proto/types.proto | 146 +++++ .../proto/validator_node.proto | 132 +++++ .../minotari_app_grpc/proto/wallet.proto | 348 ++++++++++++ 8 files changed, 1636 insertions(+) create mode 100644 applications/minotari_app_grpc/proto/base_node.proto create mode 100644 applications/minotari_app_grpc/proto/block.proto create mode 100644 applications/minotari_app_grpc/proto/network.proto create mode 100644 applications/minotari_app_grpc/proto/sidechain_types.proto create mode 100644 applications/minotari_app_grpc/proto/transaction.proto create mode 100644 applications/minotari_app_grpc/proto/types.proto create mode 100644 applications/minotari_app_grpc/proto/validator_node.proto create mode 100644 applications/minotari_app_grpc/proto/wallet.proto diff --git a/applications/minotari_app_grpc/proto/base_node.proto b/applications/minotari_app_grpc/proto/base_node.proto new file mode 100644 index 0000000..84b7f07 --- /dev/null +++ b/applications/minotari_app_grpc/proto/base_node.proto @@ -0,0 +1,517 @@ +// 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: +// +// 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. +syntax = "proto3"; + +import "types.proto"; +import "transaction.proto"; +import "block.proto"; +import "network.proto"; +import "sidechain_types.proto"; + +package tari.rpc; + +// The gRPC interface for interacting with the base node. +service BaseNode { + // Lists headers in the current best chain + rpc ListHeaders(ListHeadersRequest) returns (stream BlockHeaderResponse); + // Get header by hash + rpc GetHeaderByHash(GetHeaderByHashRequest) returns (BlockHeaderResponse); + // Returns blocks in the current best chain. Currently only supports querying by height + rpc GetBlocks(GetBlocksRequest) returns (stream HistoricalBlock); + // Returns the block timing for the chain heights + rpc GetBlockTiming(HeightRequest) returns (BlockTimingResponse); + // Returns the network Constants + rpc GetConstants(BlockHeight) returns (ConsensusConstants); + // Returns Block Sizes + rpc GetBlockSize (BlockGroupRequest) returns (BlockGroupResponse); + // Returns Block Fees + rpc GetBlockFees (BlockGroupRequest) returns (BlockGroupResponse); + // Get Version + rpc GetVersion(Empty) returns (StringValue); + // Check for new updates + rpc CheckForUpdates(Empty) returns (SoftwareUpdate); + // Get coins in circulation + rpc GetTokensInCirculation(GetBlocksRequest) returns (stream ValueAtHeightResponse); + // Get network difficulties + rpc GetNetworkDifficulty(HeightRequest) returns (stream NetworkDifficultyResponse); + // Get the block template + rpc GetNewBlockTemplate(NewBlockTemplateRequest) returns (NewBlockTemplateResponse); + // Construct a new block from a provided template + rpc GetNewBlock(NewBlockTemplate) returns (GetNewBlockResult); + // Construct a new block from a provided template + rpc GetNewBlockWithCoinbases(GetNewBlockWithCoinbasesRequest) returns (GetNewBlockResult); + // Construct a new block from a provided template + rpc GetNewBlockTemplateWithCoinbases(GetNewBlockTemplateWithCoinbasesRequest) returns (GetNewBlockResult); + // Construct a new block and header blob from a provided template + rpc GetNewBlockBlob(NewBlockTemplate) returns (GetNewBlockBlobResult); + // Submit a new block for propagation + rpc SubmitBlock(Block) returns (SubmitBlockResponse); + // Submit a new mined block blob for propagation + rpc SubmitBlockBlob(BlockBlobRequest) returns (SubmitBlockResponse); + // Submit a transaction for propagation + rpc SubmitTransaction(SubmitTransactionRequest) returns (SubmitTransactionResponse); + // Get the base node sync information + rpc GetSyncInfo(Empty) returns (SyncInfoResponse); + // Get the base node sync information + rpc GetSyncProgress(Empty) returns (SyncProgressResponse); + // Get the base node tip information + rpc GetTipInfo(Empty) returns (TipInfoResponse); + // Search for blocks containing the specified kernels + rpc SearchKernels(SearchKernelsRequest) returns (stream HistoricalBlock); + // Search for blocks containing the specified commitments + rpc SearchUtxos(SearchUtxosRequest) returns (stream HistoricalBlock); + // Fetch any utxos that exist in the main chain + rpc FetchMatchingUtxos(FetchMatchingUtxosRequest) returns (stream FetchMatchingUtxosResponse); + // get all peers from the base node + rpc GetPeers(GetPeersRequest) returns (stream GetPeersResponse); + rpc GetMempoolTransactions(GetMempoolTransactionsRequest) returns (stream GetMempoolTransactionsResponse); + rpc TransactionState(TransactionStateRequest) returns (TransactionStateResponse); + // This returns the node's network identity + rpc Identify (Empty) returns (NodeIdentity); + // Get Base Node network connectivity status + rpc GetNetworkStatus(Empty) returns (NetworkStatusResponse); + // List currently connected peers + rpc ListConnectedPeers(Empty) returns (ListConnectedPeersResponse); + // Get mempool stats + rpc GetMempoolStats(Empty) returns (MempoolStatsResponse); + // Get VNs + rpc GetActiveValidatorNodes(GetActiveValidatorNodesRequest) returns (stream GetActiveValidatorNodesResponse); + rpc GetShardKey(GetShardKeyRequest) returns (GetShardKeyResponse); + // Get templates + rpc GetTemplateRegistrations(GetTemplateRegistrationsRequest) returns (stream GetTemplateRegistrationResponse); + rpc GetSideChainUtxos(GetSideChainUtxosRequest) returns (stream GetSideChainUtxosResponse); +} + +message GetAssetMetadataRequest { + bytes asset_public_key = 1; +} + +message GetAssetMetadataResponse { + string name = 2; + string description =3; + string image = 4; + bytes owner_commitment = 5; + OutputFeatures features = 6; + uint64 mined_height = 7; + bytes mined_in_block = 8; +} + +message ListAssetRegistrationsRequest { + uint64 offset = 2; + uint64 count = 3; +} + +message ListAssetRegistrationsResponse { + bytes asset_public_key = 1; + bytes unique_id = 2; + bytes owner_commitment = 3; + uint64 mined_height = 4; + bytes mined_in_block = 5; + OutputFeatures features = 6; + bytes script = 7; +} + +message GetTokensRequest { + bytes asset_public_key = 1; + // Optionally get a set of specific unique_ids + repeated bytes unique_ids = 2; +} + +message GetTokensResponse { + bytes unique_id = 1; + bytes asset_public_key = 2; + bytes owner_commitment = 3; + bytes mined_in_block = 4; + uint64 mined_height = 5; + OutputFeatures features = 6; + bytes script = 7; +} + +message SubmitBlockResponse { + bytes block_hash = 1; +} + +message BlockBlobRequest{ + bytes header_blob = 1; + bytes body_blob = 2; +} + +/// return type of GetTipInfo +message TipInfoResponse { + MetaData metadata = 1; + bool initial_sync_achieved = 2; + BaseNodeState base_node_state = 3; +} + +enum BaseNodeState{ + START_UP = 0; + HEADER_SYNC = 1; + HORIZON_SYNC = 2; + CONNECTING = 3; + BLOCK_SYNC = 4; + LISTENING = 5; + SYNC_FAILED = 6; +} + +/// return type of GetNewBlockTemplate +message NewBlockTemplateResponse { + NewBlockTemplate new_block_template = 1; + bool initial_sync_achieved = 3; + MinerData miner_data = 4; +} + +/// return type of NewBlockTemplateRequest +message NewBlockTemplateRequest{ + PowAlgo algo = 1; + //This field should be moved to optional once optional keyword is standard + uint64 max_weight = 2; +} + +/// return type of NewBlockTemplateRequest +message GetNewBlockTemplateWithCoinbasesRequest{ + PowAlgo algo = 1; + //This field should be moved to optional once optional keyword is standard + uint64 max_weight = 2; + repeated NewBlockCoinbase coinbases = 3; +} + +/// request type of GetNewBlockWithCoinbasesRequest +message GetNewBlockWithCoinbasesRequest{ + NewBlockTemplate new_template = 1; + repeated NewBlockCoinbase coinbases = 2; +} + +message NewBlockCoinbase{ + string address = 1; + uint64 value = 2; + bool stealth_payment= 3; + bool revealed_value_proof= 4; + bytes coinbase_extra =5; +} + +// Network difficulty response +message NetworkDifficultyResponse { + uint64 difficulty = 1; + uint64 estimated_hash_rate = 2; + uint64 height = 3; + uint64 timestamp = 4; + uint64 pow_algo = 5; + uint64 sha3x_estimated_hash_rate = 6; + uint64 randomx_estimated_hash_rate = 7; +} + +// A generic single value response for a specific height +message ValueAtHeightResponse { + uint64 value= 1; + uint64 height = 2; +} + +// A generic uint value +message IntegerValue { + uint64 value = 1; +} + +// A generic String value +message StringValue { + string value = 1; +} + +/// GetBlockSize / GetBlockFees Request +/// Either the starting and ending heights OR the from_tip param must be specified +message BlockGroupRequest { + // The height from the chain tip (optional) + uint64 from_tip = 1; + // The starting height (optional) + uint64 start_height = 2; + // The ending height (optional) + uint64 end_height = 3; + /// The type of calculation required (optional) + /// Defaults to median + /// median, mean, quartile, quantile + CalcType calc_type = 4; +} + +/// GetBlockSize / GetBlockFees Response +message BlockGroupResponse { + repeated double value = 1; + CalcType calc_type = 2; +} + +enum CalcType { + MEAN = 0; + MEDIAN = 1; + QUANTILE = 2; + QUARTILE = 3; +} + +// The request used for querying a function that requires a height, either between 2 points or from the chain tip +// If start_height and end_height are set and > 0, they take precedence, otherwise from_tip is used +message HeightRequest { + // The height from the chain tip (optional) + uint64 from_tip = 1; + // The starting height (optional) + uint64 start_height = 2; + // The ending height (optional) + uint64 end_height = 3; +} + +// The return type of the rpc GetBlockTiming +message BlockTimingResponse { + uint64 max = 1; + uint64 min = 2; + double avg = 3; +} + +// Request that returns a header based by hash +message GetHeaderByHashRequest { + // The hash of the block header + bytes hash = 1; +} + + +message BlockHeaderResponse { + // The block header + BlockHeader header = 1; + // The number of blocks from the tip of this block (a.k.a depth) + uint64 confirmations = 2; + // The block reward i.e mining reward + fees + uint64 reward = 3; + // Achieved difficulty + uint64 difficulty = 4; + // The number of transactions contained in the block + uint32 num_transactions = 5; +} + +// The request used for querying headers from the base node. The parameters `from_height` and `num_headers` can be used +// to page through the current best chain. +message ListHeadersRequest { + // The height to start at. Depending on sorting, will either default to use the tip or genesis block, for `SORTING_DESC` + // and `SORTING_ASC` respectively, if a value is not provided. The first header returned will be at this height + // followed by `num_headers` - 1 headers in the direction specified by `sorting`. If greater than the current tip, + // the current tip will be used. + uint64 from_height = 1; + // The number of headers to return. If not specified, it will default to 10 + uint64 num_headers = 2; + // The ordering to return the headers in. If not specified will default to SORTING_DESC. Note that if `from_height` + // is not specified or is 0, if `sorting` is SORTING_DESC, the tip will be used as `from_height`, otherwise the + // block at height 0 will be used. + Sorting sorting = 3; +} + +// The request used for querying blocks in the base node's current best chain. Currently only querying by height is +// available. Multiple blocks may be queried.e.g. [189092,100023,122424]. The order in which they are returned is not +// guaranteed. +message GetBlocksRequest { + repeated uint64 heights = 1; +} + +// The return type of the rpc GetBlocks. Blocks are not guaranteed to be returned in the order requested. +message GetBlocksResponse { + repeated HistoricalBlock blocks = 1; +} + +enum Sorting { + SORTING_DESC = 0; + SORTING_ASC = 1; +} + +message MetaData { + // The current chain height, or the block number of the longest valid chain, or `None` if there is no chain + uint64 best_block_height = 1; + // The block hash of the current tip of the longest valid chain, or `None` for an empty chain + bytes best_block_hash = 2; + // This is the min height this node can provide complete blocks for. A 0 here means this node is archival and can provide complete blocks for every height. + uint64 pruned_height = 6; + // The current geometric mean of the pow of the chain tip, or `None` if there is no chain + bytes accumulated_difficulty = 5; +} + +message SyncInfoResponse { + uint64 tip_height = 1; + uint64 local_height = 2; + repeated bytes peer_node_id = 3; +} + +message SyncProgressResponse { + uint64 tip_height = 1; + uint64 local_height = 2; + SyncState state = 3; +} + +enum SyncState { + STARTUP = 0; + HEADER_STARTING = 1; + HEADER = 2; + BLOCK_STARTING = 3; + BLOCK = 4; + DONE = 5; +} + +// This is the message that is returned for a miner after it asks for a new block. +message GetNewBlockResult{ + // This is the header hash of the completed block + bytes block_hash = 1; + // This is the completed block + Block block = 2; + bytes merge_mining_hash =3; + bytes tari_unique_id =4; + MinerData miner_data = 5; +} + +// This is the message that is returned for a miner after it asks for a new block. +message GetNewBlockBlobResult{ + // This is the header hash of the completed block + bytes block_hash = 1; + // This is the completed block's header + bytes header = 2; + // This is the completed block's body + bytes block_body = 3; + bytes merge_mining_hash =4; + bytes utxo_mr = 5; + bytes tari_unique_id =6; +} + +// This is mining data for the miner asking for a new block +message MinerData{ + PowAlgo algo = 1; + uint64 target_difficulty = 2; + uint64 reward = 3; +// bytes merge_mining_hash =4; + uint64 total_fees = 5; +} + +// This is the request type for the Search Kernels rpc +message SearchKernelsRequest{ + repeated Signature signatures = 1; +} + +// This is the request type for the Search Utxo rpc +message SearchUtxosRequest{ + repeated bytes commitments = 1; +} + +message FetchMatchingUtxosRequest { + repeated bytes hashes = 1; +} + +message FetchMatchingUtxosResponse { + TransactionOutput output = 1; +} + +// This is the request type of the get all peers rpc call +message GetPeersResponse{ + Peer peer = 1; +} + +message GetPeersRequest{} + +message SubmitTransactionRequest { + Transaction transaction = 1; +} + +message SubmitTransactionResponse { + SubmitTransactionResult result =1; +} + +enum SubmitTransactionResult { + NONE = 0; + ACCEPTED = 1; + NOT_PROCESSABLE_AT_THIS_TIME = 2; + ALREADY_MINED = 3; + REJECTED = 4; + +} + +message GetMempoolTransactionsRequest { + +} + +message GetMempoolTransactionsResponse { + Transaction transaction = 1; +} + +message TransactionStateRequest { + Signature excess_sig = 1; +} + +message TransactionStateResponse { + TransactionLocation result =1; +} + +enum TransactionLocation { + UNKNOWN = 0; + MEMPOOL = 1; + MINED = 2; + NOT_STORED = 3; +} + +message MempoolStatsResponse { + uint64 unconfirmed_txs = 2; + uint64 reorg_txs = 3; + uint64 unconfirmed_weight = 4; +} + +message GetActiveValidatorNodesRequest { + uint64 height = 1; +} + +message GetActiveValidatorNodesResponse { + bytes shard_key = 1; + bytes public_key = 2; +} + +message GetShardKeyRequest { + uint64 height = 1; + bytes public_key = 2; +} + +message GetShardKeyResponse { + bytes shard_key = 1; + bool found = 2; +} + +message GetTemplateRegistrationsRequest { + bytes start_hash = 1; + uint64 count = 2; +} + +message GetTemplateRegistrationResponse { + bytes utxo_hash = 1; + TemplateRegistration registration = 2; +} + +message BlockInfo { + uint64 height = 1; + bytes hash = 2; + bytes next_block_hash = 3; +} + +message GetSideChainUtxosRequest { + bytes start_hash = 1; + uint64 count = 2; +} + +message GetSideChainUtxosResponse { + BlockInfo block_info = 1; + repeated TransactionOutput outputs = 2; +} + diff --git a/applications/minotari_app_grpc/proto/block.proto b/applications/minotari_app_grpc/proto/block.proto new file mode 100644 index 0000000..f5ed70c --- /dev/null +++ b/applications/minotari_app_grpc/proto/block.proto @@ -0,0 +1,137 @@ +// 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: +// +// 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. +syntax = "proto3"; + +package tari.rpc; + +import "transaction.proto"; + +// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block +// and the transaction kernels. +message BlockHeader { + // The hash of the block + bytes hash = 1; + // Version of the block + uint32 version = 2; + // Height of this block since the genesis block (height 0) + uint64 height = 3; + // Hash of the block previous to this in the chain. + bytes prev_hash = 4; + // Timestamp at which the block was built. + uint64 timestamp = 5; + // This is the UTXO merkle root of the outputs + // This is calculated as Hash (txo MMR root || roaring bitmap hash of UTXO indices) + bytes output_mr = 6; + // This is the MMR root of the kernels + bytes kernel_mr = 8; + // This is the Merkle root of the inputs in this block + bytes input_mr = 9; + // Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this* + // block from the total kernel offset of the previous block header. + bytes total_kernel_offset = 10; + // Nonce increment used to mine this block. + uint64 nonce = 11; + // Proof of work metadata + ProofOfWork pow = 12; + // Kernel MMR size + uint64 kernel_mmr_size = 13; + // Output MMR size + uint64 output_mmr_size = 14; + // Sum of script offsets for all kernels in this block. + bytes total_script_offset = 15; + // Merkle root of validator nodes + bytes validator_node_mr = 16; + // Validator size + uint64 validator_node_size = 17; +} + +// The proof of work data structure that is included in the block header. +message ProofOfWork { + // The algorithm used to mine this block + // 0 = Monero + // 1 = Sha3X + uint64 pow_algo = 1; + // Supplemental proof of work data. For example for Sha3x, this would be empty (only the block header is + // required), but for Monero merge mining we need the Monero block header and RandomX seed hash. + bytes pow_data = 4; +} + +//This is used to request the which pow algo should be used with the block template +message PowAlgo { + // The permitted pow algorithms + enum PowAlgos { + POW_ALGOS_RANDOMX = 0; // Accessible as `grpc::pow_algo::PowAlgos::Randomx` + POW_ALGOS_SHA3X = 1; // Accessible as `grpc::pow_algo::PowAlgos::Sha3x` + } + // The pow algo to use + PowAlgos pow_algo = 1; +} + + +// A Minotari block. Blocks are linked together into a blockchain. +message Block { + // The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block + // and the transaction kernels. + BlockHeader header = 1; + // The components of the block or transaction. The same struct can be used for either, since in Mimblewimble, + // blocks consist of inputs, outputs and kernels, rather than transactions. + AggregateBody body = 2; +} + +// The representation of a historical block in the blockchain. It is essentially identical to a protocol-defined +// block but contains some extra metadata that clients such as Block Explorers will find interesting. +message HistoricalBlock { + // The number of blocks that have been mined since this block, including this one. The current tip will have one + // confirmation. + uint64 confirmations = 1; + // The underlying block + Block block = 2; +} + + +// The NewBlockHeaderTemplate is used for the construction of a new mine-able block. It contains all the metadata for the block that the Base Node is able to complete on behalf of a Miner. +message NewBlockHeaderTemplate { + // Version of the block + uint32 version = 1; + // Height of this block since the genesis block (height 0) + uint64 height = 2; + // Hash of the block previous to this in the chain. + bytes prev_hash = 3; + // Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this* + // block from the total kernel offset of the previous block header. + bytes total_kernel_offset = 4; + // Proof of work metadata + ProofOfWork pow = 5; + // Sum of script offsets for all kernels in this block. + bytes total_script_offset = 7; +} + +// The new block template is used constructing a new partial block, allowing a miner to added the coinbase utxo and as a final step the Base node to add the MMR roots to the header. +message NewBlockTemplate { + // The NewBlockHeaderTemplate is used for the construction of a new mineable block. It contains all the metadata for + // the block that the Base Node is able to complete on behalf of a Miner. + NewBlockHeaderTemplate header = 1; + // This flag indicates if the inputs, outputs and kernels have been sorted internally, that is, the sort() method + // has been called. This may be false even if all components are sorted. + AggregateBody body = 2; +} + diff --git a/applications/minotari_app_grpc/proto/network.proto b/applications/minotari_app_grpc/proto/network.proto new file mode 100644 index 0000000..fba0614 --- /dev/null +++ b/applications/minotari_app_grpc/proto/network.proto @@ -0,0 +1,97 @@ +// 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: +// +// 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. +syntax = "proto3"; + +package tari.rpc; + +import "google/protobuf/timestamp.proto"; + +message NodeIdentity { + bytes public_key = 1; + repeated string public_addresses = 2; + bytes node_id = 3; +} + +message Peer { + /// Public key of the peer + bytes public_key =1; + /// NodeId of the peer + bytes node_id =2; + /// Peer's addresses + repeated Address addresses = 3; + /// Last connection attempt to peer + uint64 last_connection = 4; + /// Flags for the peer. + uint32 flags = 5; + uint64 banned_until= 6; + string banned_reason= 7; + uint64 offline_at = 8; + /// Features supported by the peer + uint32 features = 9; + /// used as information for more efficient protocol negotiation. + repeated bytes supported_protocols = 11; + /// User agent advertised by the peer + string user_agent = 12; +} + +enum ConnectivityStatus { + Initializing = 0; + Online = 1; + Degraded = 2; + Offline = 3; +} + +message NetworkStatusResponse { + ConnectivityStatus status = 1; + uint32 avg_latency_ms = 2; + uint32 num_node_connections = 3; +} + +message Address{ + bytes address =1; + string last_seen = 2; + uint32 connection_attempts = 3; + AverageLatency avg_latency = 5; +} + +message AverageLatency { + uint64 latency = 1; +} + +message ListConnectedPeersResponse { + repeated Peer connected_peers = 1; +} + +message SoftwareUpdate { + bool has_update = 1; + string version = 2; + string sha = 3; + string download_url = 4; +} + +message GetIdentityRequest { } + +message GetIdentityResponse { + bytes public_key = 1; + string public_address = 2; + bytes node_id = 3; +} diff --git a/applications/minotari_app_grpc/proto/sidechain_types.proto b/applications/minotari_app_grpc/proto/sidechain_types.proto new file mode 100644 index 0000000..184a321 --- /dev/null +++ b/applications/minotari_app_grpc/proto/sidechain_types.proto @@ -0,0 +1,77 @@ +// 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: +// +// 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. +syntax = "proto3"; + +package tari.rpc; + +import "types.proto"; + +message SideChainFeature { + oneof side_chain_feature { + ValidatorNodeRegistration validator_node_registration = 1; + TemplateRegistration template_registration = 2; + ConfidentialOutputData confidential_output = 3; + } +} + +message ValidatorNodeRegistration { + bytes public_key = 1; + Signature signature = 2; +} + +message TemplateRegistration { + bytes author_public_key = 1; + Signature author_signature = 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; +} + +message ConfidentialOutputData { + bytes claim_public_key = 1; +} + +message TemplateType { + oneof template_type { + WasmInfo wasm = 1; + FlowInfo flow = 2; + ManifestInfo manifest = 3; + } +} + +message WasmInfo { + uint32 abi_version = 1; +} + +message FlowInfo { +} + +message ManifestInfo { +} + +message BuildInfo { + string repo_url = 1; + bytes commit_hash = 2; +} diff --git a/applications/minotari_app_grpc/proto/transaction.proto b/applications/minotari_app_grpc/proto/transaction.proto new file mode 100644 index 0000000..8133e70 --- /dev/null +++ b/applications/minotari_app_grpc/proto/transaction.proto @@ -0,0 +1,182 @@ +// 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: +// +// 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. +syntax = "proto3"; + +package tari.rpc; + +import "types.proto"; +import "sidechain_types.proto"; + +// The transaction kernel tracks the excess for a given transaction. For an explanation of what the excess is, and +// why it is necessary, refer to the +// [Mimblewimble TLU post](https://tlu.tarilabs.com/protocols/mimblewimble-1/sources/PITCHME.link.html?highlight=mimblewimble#mimblewimble). +// The kernel also tracks other transaction metadata, such as the lock height for the transaction (i.e. the earliest +// this transaction can be mined) and the transaction fee, in cleartext. +message TransactionKernel { + // Options for a kernel's structure or use + uint32 features = 1; + /// Fee originally included in the transaction this proof is for (in MicroMinotari) + uint64 fee = 2; + // This kernel is not valid earlier than lock_height blocks + // The max lock_height of all *inputs* to this transaction + uint64 lock_height = 3; + // Remainder of the sum of all transaction commitments. If the transaction + // is well formed, amounts components should sum to zero and the excess + // is hence a valid public key. + bytes excess = 6; + // The signature proving the excess is a valid public key, which signs + // the transaction fee. + Signature excess_sig = 7; + // The hash of the kernel, as it appears in the MMR + bytes hash = 8; + // Version + uint32 version = 9; + // Optional burned commitment + bytes burn_commitment = 10; +} + +// A transaction input. +// +// Primarily a reference to an output being spent by the transaction. +message TransactionInput { + // The features of the output being spent. We will check maturity for all outputs. + OutputFeatures features = 1; + // The commitment referencing the output being spent. + bytes commitment = 2; + // Hash of the input, as it appears in the MMR + bytes hash = 3; + // The serialised script + bytes script = 4; + // The script input data, if any + bytes input_data = 5; + // A signature with k_s, signing the script, input data, and mined height + ComAndPubSignature script_signature = 7; + // The offset public key, K_O + bytes sender_offset_public_key = 8; + // The hash of the output this input is spending + bytes output_hash = 9; + // Covenant + bytes covenant = 10; + // Version + uint32 version = 11; + // The encrypted data + bytes encrypted_data = 12; + // The minimum value of the commitment that is proven by the range proof (in MicroMinotari) + uint64 minimum_value_promise = 13; + // The metadata signature for output this input is spending + ComAndPubSignature metadata_signature = 14; + // The rangeproof hash for output this input is spending + bytes rangeproof_hash = 15; +} + +// Output for a transaction, defining the new ownership of coins that are being transferred. The commitment is a +// blinded value for the output while the range proof guarantees the commitment includes a positive value without +// overflow and the ownership of the private key. +message TransactionOutput { + // Options for an output's structure or use + OutputFeatures features = 1; + // The homomorphic commitment representing the output amount + bytes commitment = 2; + // A proof that the commitment is in the right range + RangeProof range_proof = 3; + // The hash of the output, as it appears in the MMR + bytes hash = 4; + // Tari script serialised script + bytes script = 5; + // Tari script offset public key, K_O + bytes sender_offset_public_key = 6; + // Metadata signature with the homomorphic commitment private values (amount and blinding factor) and the sender + // offset private key + ComAndPubSignature metadata_signature = 7; + // Covenant + bytes covenant = 8; + // Version + uint32 version = 9; + // Encrypted Pedersen commitment openings (value and mask) for the output + bytes encrypted_data = 10; + // The minimum value of the commitment that is proven by the range proof (in MicroMinotari) + uint64 minimum_value_promise = 11; +} + +// Options for UTXOs +message OutputFeatures { + // Version + uint32 version = 1; + // The type of output, eg Coinbase, all of which have different consensus rules + uint32 output_type = 2; + // The maturity of the specific UTXO. This is the min lock height at which an UTXO can be spend. Coinbase UTXO + // require a min maturity of the Coinbase_lock_height, this should be checked on receiving new blocks. + uint64 maturity = 3; + // Additional arbitrary info in coinbase transactions supplied by miners + bytes coinbase_extra = 4; + // Features that are specific to a side chain + SideChainFeature sidechain_feature = 5; + // The type of range proof used in the output + uint32 range_proof_type = 6; +} + +// The components of the block or transaction. The same struct can be used for either, since in Mimblewimble, +// cut-through means that blocks and transactions have the same structure. The inputs, outputs and kernels should +// be sorted by their Blake2b-256bit digest hash +message AggregateBody { + // List of inputs spent by the transaction. + repeated TransactionInput inputs = 1; + // List of outputs the transaction produces. + repeated TransactionOutput outputs = 2; + // Kernels contain the excesses and their signatures for transaction + repeated TransactionKernel kernels = 3; +} + +// A transaction which consists of a kernel offset and an aggregate body made up of inputs, outputs and kernels. +message Transaction { + bytes offset = 1; + AggregateBody body = 2; + bytes script_offset = 3; +} + +message UnblindedOutput { + // Value of the output + uint64 value = 1; + // Spending key of the output + bytes spending_key = 2; + // Options for an output's structure or use + OutputFeatures features = 3; + // Tari script serialised script + bytes script = 4; + // Tari script input data for spending + bytes input_data = 5; + // Tari script private key + bytes script_private_key = 7; + // Tari script offset pubkey, K_O + bytes sender_offset_public_key = 8; + // UTXO signature with the script offset private key, k_O + ComAndPubSignature metadata_signature = 9; + // The minimum height the script allows this output to be spent + uint64 script_lock_height = 10; + // Covenant + bytes covenant = 11; + // Encrypted data + bytes encrypted_data = 12; + // The minimum value of the commitment that is proven by the range proof (in MicroMinotari) + uint64 minimum_value_promise = 13; +} + diff --git a/applications/minotari_app_grpc/proto/types.proto b/applications/minotari_app_grpc/proto/types.proto new file mode 100644 index 0000000..c652dbd --- /dev/null +++ b/applications/minotari_app_grpc/proto/types.proto @@ -0,0 +1,146 @@ +// 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: +// +// 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. +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; +} + +/// An Empty placeholder for endpoints without request parameters +message Empty {} + +/// Define an interface for block height +message BlockHeight { + 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. +message Signature { + 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. +message ComAndPubSignature { + 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 +message CommitmentSignature { + 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; +} + +/// Weight params +message WeightParams { + 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; +} + +/// Output types +enum OutputType { + 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; +} + +message PermittedRangeProofs { + OutputType output_type = 1; + repeated RangeProofType range_proof_types = 2; +} + +/// Range proof +message RangeProof { + 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 [deprecated=true]; + 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 PermittedRangeProofs permitted_range_proof_types = 34; + uint64 inflation_bips = 35; + uint64 tail_epoch_length = 36; +} diff --git a/applications/minotari_app_grpc/proto/validator_node.proto b/applications/minotari_app_grpc/proto/validator_node.proto new file mode 100644 index 0000000..9b8d73e --- /dev/null +++ b/applications/minotari_app_grpc/proto/validator_node.proto @@ -0,0 +1,132 @@ +// Copyright 2021. 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. +syntax = "proto3"; + +import "types.proto"; +import "network.proto"; +import "transaction.proto"; + +package tari.rpc; + +service ValidatorNode { + rpc GetIdentity(GetIdentityRequest) returns (GetIdentityResponse); + rpc GetMetadata(GetMetadataRequest) returns (GetMetadataResponse); + rpc GetTokenData(GetTokenDataRequest) returns (GetTokenDataResponse); +// rpc ExecuteInstruction(ExecuteInstructionRequest) returns (ExecuteInstructionResponse); + rpc InvokeReadMethod(InvokeReadMethodRequest) returns (InvokeReadMethodResponse); + rpc InvokeMethod(InvokeMethodRequest) returns (InvokeMethodResponse); + rpc GetConstitutionRequests(GetConstitutionRequestsRequest) returns (stream TransactionOutput); + rpc PublishContractAcceptance(PublishContractAcceptanceRequest) returns (PublishContractAcceptanceResponse); + rpc PublishContractUpdateProposalAcceptance(PublishContractUpdateProposalAcceptanceRequest) returns (PublishContractUpdateProposalAcceptanceResponse); +} + +message GetConstitutionRequestsRequest { + // empty +} + +message GetMetadataRequest { + // empty +} + +message PublishContractAcceptanceRequest { + bytes contract_id = 1; +} + +message PublishContractAcceptanceResponse { + string status = 1; + uint64 tx_id = 2; +} + +message PublishContractUpdateProposalAcceptanceRequest { + bytes contract_id = 1; + uint64 proposal_id = 2; +} + +message PublishContractUpdateProposalAcceptanceResponse { + string status = 1; + uint64 tx_id = 2; +} + +message GetMetadataResponse { + repeated SidechainMetadata sidechains = 1; +} + +message SidechainMetadata { + bytes asset_public_key =1; + uint64 committed_height = 2; + bytes committed_hash = 3; +} + +message GetTokenDataRequest { + bytes asset_pub_key = 1; + bytes unique_id = 2; +} + +message GetTokenDataResponse { + +} + +//message ExecuteInstructionRequest{ +// bytes asset_public_key = 1; +// uint32 template_id = 2; +// string method = 3; +// bytes args = 4; +//// bytes token_id = 5; +//// bytes signature = 6; +//} +// +//message ExecuteInstructionResponse { +// string status = 1; +// optional bytes result = 2; +//} + +message InvokeReadMethodRequest{ + bytes contract_id = 1; + uint32 template_id = 2; + string method = 3; + bytes args = 4; + bytes sender = 5; +} + +message InvokeReadMethodResponse { + bytes result = 1; + Authority authority = 2; +} + +message Authority { + bytes node_public_key =1; + bytes signature = 2; + bytes proxied_by = 3; +} + +message InvokeMethodRequest { + bytes contract_id = 1; + uint32 template_id = 2; + string method = 3; + bytes args = 4; + bytes sender = 5; +} + +message InvokeMethodResponse { + string status = 1; + bytes result = 2; +} diff --git a/applications/minotari_app_grpc/proto/wallet.proto b/applications/minotari_app_grpc/proto/wallet.proto new file mode 100644 index 0000000..c822685 --- /dev/null +++ b/applications/minotari_app_grpc/proto/wallet.proto @@ -0,0 +1,348 @@ +// 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: +// +// 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. +syntax = "proto3"; + +package tari.rpc; + +import "google/protobuf/timestamp.proto"; +import "types.proto"; +import "transaction.proto"; +import "sidechain_types.proto"; +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 { } + + +message GetVersionResponse { + string version = 1; +} + +message GetAddressResponse { + bytes address = 1; +} + +message TransferRequest { + repeated PaymentRecipient recipients = 1; +} + +message SendShaAtomicSwapRequest { + PaymentRecipient recipient = 1; +} + +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; +} + +message TransferResponse { + repeated TransferResult results = 1; +} + +message SendShaAtomicSwapResponse { + 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 TransferResult { + 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 ClaimShaAtomicSwapResponse { + TransferResult results = 1; +} + +message ClaimHtlcRefundRequest{ + string output_hash = 1; + uint64 fee_per_gram = 2; +} + +message ClaimHtlcRefundResponse { + TransferResult results = 1; +} + +message GetTransactionInfoRequest { + repeated uint64 transaction_ids = 1; +} + +message GetTransactionInfoResponse { + 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; +} + +enum TransactionDirection { + 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 { } + +message GetCompletedTransactionsResponse { + TransactionInfo transaction = 1; +} + +message GetBalanceRequest { } + +message GetBalanceResponse { + uint64 available_balance = 1; + uint64 pending_incoming_balance = 2; + uint64 pending_outgoing_balance = 3; + uint64 timelocked_balance = 4; +} + +message GetUnspentAmountsResponse { + 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; +} + +message CoinSplitResponse { + uint64 tx_id = 1; +} + +message ImportUtxosRequest { + repeated UnblindedOutput outputs = 1; +} + +message ImportUtxosResponse { + repeated uint64 tx_ids = 1; +} + +message CreateTemplateRegistrationRequest { + TemplateRegistration template_registration = 1; + uint64 fee_per_gram = 2; +} + +message CreateTemplateRegistrationResponse { + uint64 tx_id = 1; + bytes template_address = 2; +} + +message CancelTransactionRequest { + uint64 tx_id = 1; +} + +message CancelTransactionResponse { + bool is_success = 1; + string failure_message = 2; +} + +message RevalidateRequest{} + +message RevalidateResponse{} + +message ValidateRequest{} + +message ValidateResponse{} + +message SetBaseNodeRequest { + string public_key_hex = 1; + string net_address = 2; +} + +message SetBaseNodeResponse{} + +message GetConnectivityRequest{} + +message CheckConnectivityResponse{ + enum OnlineStatus { + Connecting = 0; + Online = 1; + Offline = 2; + } + OnlineStatus status = 1; +} + +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; +} + +message TransactionEventResponse { + TransactionEvent transaction = 1; +} + +message RegisterValidatorNodeRequest { + bytes validator_node_public_key = 1; + Signature validator_node_signature = 2; + uint64 fee_per_gram = 3; + string message = 4; +} + +message RegisterValidatorNodeResponse { + uint64 transaction_id = 1; + bool is_success = 2; + string failure_message = 3; +}