|
|
@ -1,5 +1,3 @@ |
|
|
|
// File generated by github.com/ebuchman/rpc-gen
|
|
|
|
|
|
|
|
package rpc |
|
|
|
|
|
|
|
import ( |
|
|
@ -13,27 +11,27 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
type Client interface { |
|
|
|
Status() (*core.ResponseStatus, error) |
|
|
|
DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) |
|
|
|
ListAccounts() (*core.ResponseListAccounts, error) |
|
|
|
BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) |
|
|
|
GetBlock(height uint) (*core.ResponseGetBlock, error) |
|
|
|
BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) |
|
|
|
NetInfo() (*core.ResponseNetInfo, error) |
|
|
|
Call(address []byte) (*core.ResponseCall, error) |
|
|
|
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) |
|
|
|
ListValidators() (*core.ResponseListValidators, error) |
|
|
|
DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) |
|
|
|
GenPrivAccount() (*core.ResponseGenPrivAccount, error) |
|
|
|
GetAccount(address []byte) (*core.ResponseGetAccount, error) |
|
|
|
GetBlock(height uint) (*core.ResponseGetBlock, error) |
|
|
|
GetStorage(address []byte) (*core.ResponseGetStorage, error) |
|
|
|
ListAccounts() (*core.ResponseListAccounts, error) |
|
|
|
ListValidators() (*core.ResponseListValidators, error) |
|
|
|
NetInfo() (*core.ResponseNetInfo, error) |
|
|
|
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) |
|
|
|
Status() (*core.ResponseStatus, error) |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) Status() (*core.ResponseStatus, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
func (c *ClientHTTP) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) { |
|
|
|
values, err := argsToURLValues([]string{"minHeight"}, minHeight) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"status", values) |
|
|
|
resp, err := http.PostForm(c.addr+"blockchain_info", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -43,10 +41,10 @@ func (c *ClientHTTP) Status() (*core.ResponseStatus, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseStatus `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseBlockchainInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -58,12 +56,12 @@ func (c *ClientHTTP) Status() (*core.ResponseStatus, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) { |
|
|
|
values, err := argsToURLValues([]string{"addr"}, addr) |
|
|
|
func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) { |
|
|
|
values, err := argsToURLValues([]string{"tx"}, tx) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"dump_storage", values) |
|
|
|
resp, err := http.PostForm(c.addr+"broadcast_tx", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -73,7 +71,7 @@ func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseDumpStorage `json:"result"` |
|
|
|
Result *core.ResponseBroadcastTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
@ -88,12 +86,12 @@ func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
func (c *ClientHTTP) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
values, err := argsToURLValues([]string{"address"}, address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"list_accounts", values) |
|
|
|
resp, err := http.PostForm(c.addr+"call", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -103,10 +101,10 @@ func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseListAccounts `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseCall `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -118,12 +116,12 @@ func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) { |
|
|
|
values, err := argsToURLValues([]string{"minHeight"}, minHeight) |
|
|
|
func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) { |
|
|
|
values, err := argsToURLValues([]string{"addr"}, addr) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"blockchain_info", values) |
|
|
|
resp, err := http.PostForm(c.addr+"dump_storage", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -133,10 +131,10 @@ func (c *ClientHTTP) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInf |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseBlockchainInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseDumpStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -148,12 +146,12 @@ func (c *ClientHTTP) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInf |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
values, err := argsToURLValues([]string{"height"}, height) |
|
|
|
func (c *ClientHTTP) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"get_block", values) |
|
|
|
resp, err := http.PostForm(c.addr+"gen_priv_account", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -163,10 +161,10 @@ func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetBlock `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGenPrivAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -178,12 +176,12 @@ func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) { |
|
|
|
values, err := argsToURLValues([]string{"tx"}, tx) |
|
|
|
func (c *ClientHTTP) GetAccount(address []byte) (*core.ResponseGetAccount, error) { |
|
|
|
values, err := argsToURLValues([]string{"address"}, address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"broadcast_tx", values) |
|
|
|
resp, err := http.PostForm(c.addr+"get_account", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -193,10 +191,10 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseBroadcastTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -208,12 +206,12 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
values, err := argsToURLValues([]string{"height"}, height) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"net_info", values) |
|
|
|
resp, err := http.PostForm(c.addr+"get_block", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -223,10 +221,10 @@ func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseNetInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetBlock `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -238,12 +236,12 @@ func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error) { |
|
|
|
values, err := argsToURLValues([]string{"address"}, address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"call", values) |
|
|
|
resp, err := http.PostForm(c.addr+"get_storage", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -253,10 +251,10 @@ func (c *ClientHTTP) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseCall `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -268,12 +266,12 @@ func (c *ClientHTTP) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) { |
|
|
|
values, err := argsToURLValues([]string{"tx", "privAccounts"}, tx, privAccounts) |
|
|
|
func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"sign_tx", values) |
|
|
|
resp, err := http.PostForm(c.addr+"list_accounts", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -283,10 +281,10 @@ func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (* |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseSignTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseListAccounts `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -328,12 +326,12 @@ func (c *ClientHTTP) ListValidators() (*core.ResponseListValidators, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"gen_priv_account", values) |
|
|
|
resp, err := http.PostForm(c.addr+"net_info", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -343,10 +341,10 @@ func (c *ClientHTTP) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGenPrivAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseNetInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -358,12 +356,12 @@ func (c *ClientHTTP) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) GetAccount(address []byte) (*core.ResponseGetAccount, error) { |
|
|
|
values, err := argsToURLValues([]string{"address"}, address) |
|
|
|
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) { |
|
|
|
values, err := argsToURLValues([]string{"tx", "privAccounts"}, tx, privAccounts) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"get_account", values) |
|
|
|
resp, err := http.PostForm(c.addr+"sign_tx", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -373,10 +371,10 @@ func (c *ClientHTTP) GetAccount(address []byte) (*core.ResponseGetAccount, error |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseSignTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -388,12 +386,12 @@ func (c *ClientHTTP) GetAccount(address []byte) (*core.ResponseGetAccount, error |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error) { |
|
|
|
values, err := argsToURLValues([]string{"address"}, address) |
|
|
|
func (c *ClientHTTP) Status() (*core.ResponseStatus, error) { |
|
|
|
values, err := argsToURLValues(nil, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
resp, err := http.PostForm(c.addr+"get_storage", values) |
|
|
|
resp, err := http.PostForm(c.addr+"status", values) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -403,10 +401,10 @@ func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseStatus `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -418,26 +416,22 @@ func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) Status() (*core.ResponseStatus, error) { |
|
|
|
params, err := binaryWriter(nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "status", |
|
|
|
Params: params, |
|
|
|
Method: "blockchain_info", |
|
|
|
Params: []interface{}{minHeight}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseStatus `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseBlockchainInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -449,23 +443,19 @@ func (c *ClientJSON) Status() (*core.ResponseStatus, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) { |
|
|
|
params, err := binaryWriter(addr) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "dump_storage", |
|
|
|
Params: params, |
|
|
|
Method: "broadcast_tx", |
|
|
|
Params: []interface{}{tx}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseDumpStorage `json:"result"` |
|
|
|
Result *core.ResponseBroadcastTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
@ -480,26 +470,22 @@ func (c *ClientJSON) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
params, err := binaryWriter(nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "list_accounts", |
|
|
|
Params: params, |
|
|
|
Method: "call", |
|
|
|
Params: []interface{}{address}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseListAccounts `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseCall `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -511,26 +497,22 @@ func (c *ClientJSON) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) { |
|
|
|
params, err := binaryWriter(minHeight) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "blockchain_info", |
|
|
|
Params: params, |
|
|
|
Method: "dump_storage", |
|
|
|
Params: []interface{}{addr}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseBlockchainInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseDumpStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -542,26 +524,22 @@ func (c *ClientJSON) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInf |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
params, err := binaryWriter(height) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "get_block", |
|
|
|
Params: params, |
|
|
|
Method: "gen_priv_account", |
|
|
|
Params: []interface{}{nil}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetBlock `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGenPrivAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -573,26 +551,22 @@ func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) { |
|
|
|
params, err := binaryWriter(tx) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) GetAccount(address []byte) (*core.ResponseGetAccount, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "broadcast_tx", |
|
|
|
Params: params, |
|
|
|
Method: "get_account", |
|
|
|
Params: []interface{}{address}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseBroadcastTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -604,26 +578,22 @@ func (c *ClientJSON) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
params, err := binaryWriter(nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "net_info", |
|
|
|
Params: params, |
|
|
|
Method: "get_block", |
|
|
|
Params: []interface{}{height}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseNetInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetBlock `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -635,26 +605,22 @@ func (c *ClientJSON) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
params, err := binaryWriter(address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) GetStorage(address []byte) (*core.ResponseGetStorage, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "call", |
|
|
|
Params: params, |
|
|
|
Method: "get_storage", |
|
|
|
Params: []interface{}{address}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseCall `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseGetStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -666,26 +632,22 @@ func (c *ClientJSON) Call(address []byte) (*core.ResponseCall, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) { |
|
|
|
params, err := binaryWriter(tx, privAccounts) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) ListAccounts() (*core.ResponseListAccounts, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "sign_tx", |
|
|
|
Params: params, |
|
|
|
Method: "list_accounts", |
|
|
|
Params: []interface{}{nil}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseSignTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseListAccounts `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -698,17 +660,13 @@ func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (* |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) ListValidators() (*core.ResponseListValidators, error) { |
|
|
|
params, err := binaryWriter(nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "list_validators", |
|
|
|
Params: params, |
|
|
|
Params: []interface{}{nil}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@ -728,26 +686,22 @@ func (c *ClientJSON) ListValidators() (*core.ResponseListValidators, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
params, err := binaryWriter(nil) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) NetInfo() (*core.ResponseNetInfo, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "gen_priv_account", |
|
|
|
Params: params, |
|
|
|
Method: "net_info", |
|
|
|
Params: []interface{}{nil}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGenPrivAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseNetInfo `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -759,26 +713,22 @@ func (c *ClientJSON) GenPrivAccount() (*core.ResponseGenPrivAccount, error) { |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) GetAccount(address []byte) (*core.ResponseGetAccount, error) { |
|
|
|
params, err := binaryWriter(address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "get_account", |
|
|
|
Params: params, |
|
|
|
Method: "sign_tx", |
|
|
|
Params: []interface{}{tx, privAccounts}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetAccount `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseSignTx `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
@ -790,26 +740,22 @@ func (c *ClientJSON) GetAccount(address []byte) (*core.ResponseGetAccount, error |
|
|
|
return response.Result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ClientJSON) GetStorage(address []byte) (*core.ResponseGetStorage, error) { |
|
|
|
params, err := binaryWriter(address) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
s := JSONRPC{ |
|
|
|
func (c *ClientJSON) Status() (*core.ResponseStatus, error) { |
|
|
|
request := RPCRequest{ |
|
|
|
JSONRPC: "2.0", |
|
|
|
Method: "get_storage", |
|
|
|
Params: params, |
|
|
|
Method: "status", |
|
|
|
Params: []interface{}{nil}, |
|
|
|
Id: 0, |
|
|
|
} |
|
|
|
body, err := c.requestResponse(s) |
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var response struct { |
|
|
|
Result *core.ResponseGetStorage `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
Result *core.ResponseStatus `json:"result"` |
|
|
|
Error string `json:"error"` |
|
|
|
Id string `json:"id"` |
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
} |
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
if err != nil { |
|
|
|