syntax = "proto3";

package exchain.node.v1;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "nebula/ext/options.proto";
import "nebula/v1/account.proto";
import "nebula/v1/block.proto";
import "nebula/v1/coin.proto";
import "nebula/v1/order.proto";
import "nebula/v1/pair.proto";
import "nebula/v1/receipt.proto";
import "nebula/v1/transaction.proto";

option csharp_namespace = "ExChain.Node.V1";
option go_package = "github.com/exchain/go-exchain/exchain/protocol/node/v1";
option java_multiple_files = true;
option java_outer_classname = "NodeProto";
option java_package = "org.exchain.node.v1";
option php_namespace = "ExChain\\Node\\v1";

// define node service.
service Node {
  // blockchain api.
  rpc GetAccount(AccountRequest) returns (AccountResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_account"};
  }
  rpc GetBlockHeaderByNumber(GetHeaderRequest) returns (GetHeaderResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_block_header_by_number"};
  }
  rpc GetBlockByNumber(GetBlockRequest) returns (GetBlockResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_block_by_number"};
  }
  rpc GetBlockByHash(GetBlockRequest) returns (GetBlockResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_block_by_hash"};
  }

  rpc GetTransactionByHash(GetTransactionRequest) returns (GetTransactionResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_transaction_by_hash"};
  }

  rpc GetTransactionReceipt(GetReceiptRequest) returns (GetReceiptResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_transaction_receipt"};
  }

  rpc GetPairList(GetPairListRequest) returns (GetPairListResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_pair_list"};
  }

  rpc GetPairInfo(GetPairInfoRequest) returns (GetPairInfoResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_pair_info"};
  }

  rpc GetCoinList(GetCoinListRequest) returns (GetCoinListResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_coin_list"};
  }

  rpc GetCoinInfo(GetCoinInfoRequest) returns (GetCoinInfoResponse) {
    option (google.api.http) = {get: "/exchain/v1/node/get_coin_info"};
  }
}

message AccountRequest {
  string address = 1;
}

message AccountResponse {
  exchain.nebula.v1.Account account = 1;
}

message GetHeaderRequest {
  uint64 number = 1;
}

message GetHeaderResponse {
  exchain.nebula.v1.BlockHeader header = 1;
}

message GetBlockRequest {
  uint64 number = 1;
}

message GetBlockResponse {
  exchain.nebula.v1.Block block = 1;
}

message GetTransactionRequest {
  string hash = 1;
}

message GetTransactionResponse {
  exchain.nebula.v1.Transaction transaction = 1;
}

message GetReceiptRequest {
  string hash = 1;
}

message GetReceiptResponse {
  exchain.nebula.v1.TransactionReceipt receipt = 1;
}

message GetPairListRequest {}

message GetPairListResponse {
  repeated exchain.nebula.v1.Pair pairs = 1;
}

message GetPairInfoRequest {
  string pair_name = 1;
}

message GetPairInfoResponse {
  exchain.nebula.v1.Pair pair = 1;
}

message GetCoinListRequest {}

message GetCoinListResponse {
  repeated exchain.nebula.v1.Coin coins = 1;
}

message GetCoinInfoRequest {
  string addr = 1;
}

message GetCoinInfoResponse {
  exchain.nebula.v1.Coin coin = 1;
}
