syntax = "proto3";

import "common.proto";
import "transaction.proto";
import "blockchain.proto";
import "wallet.proto";
import "p2p.proto";
import "account.proto";
import "executor.proto";

package types;
option go_package = "github.com/33cn/chain33/types";

service chain33 {
    // chain33 对外提供服务的接口
    //区块链接口
    rpc GetBlocks(ReqBlocks) returns (Reply) {}
    //获取最新的区块头
    rpc GetLastHeader(ReqNil) returns (Header) {}
    //交易接口
    rpc CreateRawTransaction(CreateTx) returns (UnsignTx) {}
    rpc CreateRawTxGroup(CreateTransactionGroup) returns (UnsignTx) {}
    //发送签名后交易
    rpc SendRawTransaction(SignedTx) returns (Reply) {}
    // 根据哈希查询交易
    rpc QueryTransaction(ReqHash) returns (TransactionDetail) {}
    // 发送交易
    rpc SendTransaction(Transaction) returns (Reply) {}

    //通过地址获取交易信息
    rpc GetTransactionByAddr(ReqAddr) returns (ReplyTxInfos) {}

    //通过哈希数组获取对应的交易
    rpc GetTransactionByHashes(ReqHashes) returns (TransactionDetails) {}

    //缓存接口
    rpc GetMemPool(ReqNil) returns (ReplyTxList) {}

    //钱包接口
    //获取钱包账户信息
    rpc GetAccounts(ReqNil) returns (WalletAccounts) {}

    //创建钱包账户
    rpc NewAccount(ReqNewAccount) returns (WalletAccount) {}

    //获取钱包的交易列表
    rpc WalletTransactionList(ReqWalletTransactionList) returns (WalletTxDetails) {}

    //导入钱包私钥
    rpc ImportPrivkey(ReqWalletImportPrivkey) returns (WalletAccount) {}

    // 发送交易
    rpc SendToAddress(ReqWalletSendToAddress) returns (ReplyHash) {}

    //设置交易手续费
    rpc SetTxFee(ReqWalletSetFee) returns (Reply) {}

    //设置标签
    rpc SetLabl(ReqWalletSetLabel) returns (WalletAccount) {}

    //合并钱包余额
    rpc MergeBalance(ReqWalletMergeBalance) returns (ReplyHashes) {}

    //设置钱包密码
    rpc SetPasswd(ReqWalletSetPasswd) returns (Reply) {}

    //给钱包上锁
    rpc Lock(ReqNil) returns (Reply) {}

    //给钱包解锁
    rpc UnLock(WalletUnLock) returns (Reply) {}

    //获取当前节点连接的其他节点信息
    rpc GetPeerInfo(ReqNil) returns (PeerList) {}

    //获取最新的Mempool
    rpc GetLastMemPool(ReqNil) returns (ReplyTxList) {}

    // 获取钱包状态
    rpc GetWalletStatus(ReqNil) returns (WalletStatus) {}
    //区块浏览器接口
    ///
    rpc GetBlockOverview(ReqHash) returns (BlockOverview) {}
    rpc GetAddrOverview(ReqAddr) returns (AddrOverview) {}
    rpc GetBlockHash(ReqInt) returns (ReplyHash) {}
    // seed
    // 创建seed
    rpc GenSeed(GenSeedLang) returns (ReplySeed) {}
    //获取seed
    rpc GetSeed(GetSeedByPw) returns (ReplySeed) {}

    //保存seed
    rpc SaveSeed(SaveSeedByPw) returns (Reply) {}
    // Balance Query
    //获取余额
    rpc GetBalance(ReqBalance) returns (Accounts) {}

    rpc QueryChain(ChainExecutor) returns (Reply) {}
    rpc ExecWallet(ChainExecutor) returns (Reply) {}
    rpc QueryConsensus(ChainExecutor) returns (Reply) {}

    rpc CreateTransaction(CreateTxIn) returns (UnsignTx) {}
    //获取交易的十六进制编码
    rpc GetHexTxByHash(ReqHash) returns (HexTx) {}

    // 导出私钥
    rpc DumpPrivkey(ReqString) returns (ReplyString) {}

    //获取程序版本
    rpc Version(ReqNil) returns (VersionInfo) {}

    //是否同步
    rpc IsSync(ReqNil) returns (Reply) {}

    // ntpclock是否同步
    rpc IsNtpClockSync(ReqNil) returns (Reply) {}

    //获取当前节点的网络信息
    rpc NetInfo(ReqNil) returns (NodeNetInfo) {}

    //获取系统致命故障信息
    rpc GetFatalFailure(types.ReqNil) returns (Int32) {}
    rpc GetLastBlockSequence(ReqNil) returns (Int64) {}

    // get add block's sequence by hash
    rpc GetSequenceByHash(ReqHash) returns (Int64) {}

    //通过block hash 获取对应的blocks信息
    rpc GetBlockByHashes(ReqHashes) returns (BlockDetails) {}

    //通过block seq 获取对应的blocks hash 信息
    rpc GetBlockBySeq(Int64) returns (BlockSeq) {}

    //关闭chain33
    rpc CloseQueue(ReqNil) returns (Reply) {}

    //获取地址所以合约下的余额
    rpc GetAllExecBalance(ReqAllExecBalance) returns (AllExecBalance) {}
    //签名交易
    rpc SignRawTx(ReqSignRawTx) returns (ReplySignRawTx) {}

    rpc CreateNoBalanceTransaction(NoBalanceTx) returns (ReplySignRawTx) {}

    // 获取随机HASH
    rpc QueryRandNum(ReqRandHash) returns (ReplyHash) {}

    // 获取是否达到fork高度
    rpc GetFork(ReqKey) returns (Int64) {}
}
