mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
b77e533d13
And drop associated _pkg.dev remnants (refs. #307). Original `dev` branch had two separate packages for public and private keys, but those are so intertwined (`TestHelper` subpackage is a proof) that it's better unite them and all associated code (like WIF and NEP-2) in one package. This patch also: * creates internal `keytestcases` package to share things with wallet (maybe it'll be changed in some future) * ports some tests from `dev` * ports Verify() method for public key from `dev` * expands TestPrivateKey() with public key check |
||
---|---|---|
.. | ||
chains/unit_testnet | ||
result | ||
wrappers | ||
client.go | ||
doc.go | ||
errors.go | ||
neoScanBalanceGetter.go | ||
neoScanTypes.go | ||
param.go | ||
params.go | ||
README.md | ||
request.go | ||
rpc.go | ||
server.go | ||
server_test.go | ||
stack_param.go | ||
stack_param_test.go | ||
txBuilder.go | ||
txTypes.go | ||
types.go |
RPC
What
- Structs used by
JSON-RPC
server and for interacting with aJSON-RPC
endpoint. - Server for running the
JSON-RPC
protocol based on port in configuration.
This package is currently in
alpha
and is subject to change.
Reference
Client
You can create a new client and start interacting with any NEO node that exposes their
JSON-RPC
endpoint. See godocs for example.
Not all methods are currently supported in the client, please see table below for supported methods.
TODO
- Merge structs so can be used by both server and client.
- Add missing methods to client.
- Allow client to connect using client cert.
Supported methods
Method | Implemented | Required to implement |
---|---|---|
getblock |
Yes | - |
getaccountstate |
Yes | - |
invokescript |
Yes | - |
invokefunction |
Yes | - |
sendrawtransaction |
Yes | - |
invoke |
Yes | - |
getrawtransaction |
Yes | - |
validateaddress |
No | Handler and result struct |
getblocksysfee |
No | Handler and result struct |
getcontractstate |
No | Handler and result struct |
getrawmempool |
No | Handler and result struct |
getstorage |
No | Handler and result struct |
submitblock |
No | Handler and result struct |
gettxout |
No | Handler and result struct |
getassetstate |
No | Handler and result struct |
getpeers |
No | Handler and result struct |
getversion |
No | Handler and result struct |
getconnectioncount |
No | Handler and result struct |
getblockhash |
No | Handler and result struct |
getblockcount |
No | Handler and result struct |
getbestblockhash |
No | Handler and result struct |
Server
The server is written to support as much of the JSON-RPC 2.0 Spec as possible. The server is run as part of the node currently.
TODO
- Implement HTTPS server.
- Add remaining methods (Documented below).
- Add Swagger spec and test using dredd in circleCI.
Example call
An example would be viewing the version of the node:
$ curl -X POST -d '{"jsonrpc": "2.0", "method": "getversion", "params": [], "id": 1}' http://localhost:20332
which would yield the response:
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : {
"port" : 20333,
"useragent" : "/NEO-GO:0.36.0-dev/",
"nonce" : 9318417
}
}
Supported methods
Method | Implemented | Required to implement |
---|---|---|
getblock |
Yes | - |
getaccountstate |
Yes | - |
invokescript |
No | VM |
invokefunction |
No | VM |
sendrawtransaction |
No | Needs to be implemented in pkg/core/blockchain.go |
validateaddress |
Yes | - |
getblocksysfee |
No | N/A |
getcontractstate |
No | Needs to be implemented in pkg/core/blockchain.go |
getrawmempool |
No | Needs to be implemented on in pkg/network/server.go |
getrawtransaction |
No | Needs to be implemented in pkg/core/blockchain.go |
getstorage |
No | VM |
submitblock |
No | Needs to be implemented in pkg/core/blockchain.go |
gettxout |
No | Needs to be implemented in pkg/core/blockchain.go |
invoke |
No | VM |
getassetstate |
Yes | - |
getpeers |
Yes | - |
getversion |
Yes | - |
getconnectioncount |
Yes | - |
getblockhash |
Yes | - |
getblockcount |
Yes | - |
getbestblockhash |
Yes | - |