diff --git a/docs/specifications/restful_api.md b/docs/specifications/restful_api.md index 57c49afc..a1f7ed42 100644 --- a/docs/specifications/restful_api.md +++ b/docs/specifications/restful_api.md @@ -28,6 +28,7 @@ Restful Api List | get_unboundong | GET /api/v1/unboundong/:addr | | get_mempooltxcount | GET /api/v1/mempool/txcount | | get_mempooltxstate | GET /api/v1/mempool/txstate/:hash | +| get_version | GET /api/v1/version | | post_raw_tx | post /api/v1/transaction?preExec=0 | @@ -889,6 +890,28 @@ curl -i http://localhost:20334/api/v1/mempool/txcount } ``` +### 21 get_version + +Get the version information of the node. + +GET +``` +/api/v1/version +``` +#### Request Example: +``` +curl -i http://localhost:20334/api/v1/version +``` +#### Response +``` +{ + "Action": "getversion", + "Desc": "SUCCESS", + "Error": 0, + "Version": "1.0.0", + "Result": "0.9" +} +``` ## Error Code diff --git a/docs/specifications/rpc_api.md b/docs/specifications/rpc_api.md index c3390f97..df3aab53 100644 --- a/docs/specifications/rpc_api.md +++ b/docs/specifications/rpc_api.md @@ -78,8 +78,7 @@ Transaction field description | getrawtransaction | transactionhash | Returns the corresponding transaction information based on the specified hash value. | | | sendrawtransaction | hex,preExec | Broadcast transaction. | Serialized signed transactions constructed in the program into hexadecimal strings | | getstorage | script_hash | Returns the stored value according to the contract script hashes and stored key. | | -| getversion | | Get the version information of the query node | | -| getblocksysfee | | According to the specified index, return the system fee before the block. | | +| getversion | | Get the version information of the node | | | getcontractstate | script_hash,[verbose] | According to the contract script hash, query the contract information. | | | getmempooltxcount | | Query the transaction count in the memory pool. | | | getmempooltxstate | tx_hash | Query the transaction state in the memory pool. | | @@ -594,7 +593,7 @@ Response: #### 10. getversion -Get the version information of the query node. +Get the version information of the node. #### Example @@ -729,44 +728,8 @@ or > Note: If params is a number, the response result will be the txhash list. If params is txhash, the response result will be smartcode event. -#### 12. getblocksysfee -According to the specified index, return the system fee before the block. - -#### Parameter instruction - -Index: Block index - -#### Example - -Request: - -``` -{ - "jsonrpc": "2.0", - "method": "getblocksysfee", - "params": [1005434], - "id": 1 -} -``` - -Response: - -``` -{ - "desc":"SUCCESS", - "error":0, - "jsonrpc": "2.0", - "id": 1, - "result": "195500" -} -``` - -Response instruction: - -Result: The system fee before the block and the unit is OntGas. - -#### 13. getcontractstate +#### 12. getcontractstate According to the contract script hash, query the contract information. @@ -809,7 +772,7 @@ Response: } ``` -#### 14. getmempooltxstate +#### 13. getmempooltxstate Query the transaction state in the memory pool. @@ -852,7 +815,7 @@ Response: } ``` -#### 15. getmempooltxcount +#### 14. getmempooltxcount Query the transaction count in the memory pool. @@ -882,7 +845,7 @@ Response: ``` -#### 16. getblockheightbytxhash +#### 15. getblockheightbytxhash get blockheight by txhash #### Parameter instruction txhash: transaction hash @@ -910,7 +873,7 @@ Response: } ``` -#### 17. getbalance +#### 16. getbalance return balance of base58 account address. @@ -947,7 +910,7 @@ Response: } ``` -#### 18. getmerkleproof +#### 17. getmerkleproof return merkle proof @@ -1001,7 +964,7 @@ Response: } ``` -#### 19. getgasprice +#### 18. getgasprice return gasprice. @@ -1034,7 +997,7 @@ Response: } ``` -#### 20. getallowance +#### 19. getallowance return allowance. @@ -1064,7 +1027,7 @@ Response: } ``` -#### 21. getunboundong +#### 20. getunboundong return unboundong. @@ -1094,7 +1057,7 @@ Response: } ``` -#### 22 getblocktxsbyheight +#### 21 getblocktxsbyheight Get transactions by block height return all transaction hash contained in the block corresponding to this height diff --git a/docs/specifications/websocket_api.md b/docs/specifications/websocket_api.md index b3ecf45e..9a0a8cf4 100644 --- a/docs/specifications/websocket_api.md +++ b/docs/specifications/websocket_api.md @@ -838,6 +838,28 @@ Query the transaction count in the memory pool. ``` +### 25. Get version +Get the version information of the node. + +#### Request Example: +``` +{ + "Action": "getversion", + "Version": "1.0.0" +} +``` +#### Response +``` +{ + "Action": "getversion", + "Desc": "SUCCESS", + "Error": 0, + "Version": "1.0.0", + "Result": "0.9" +} +``` + + ## Error Code | Field | Type | Description | diff --git a/http/base/rest/interfaces.go b/http/base/rest/interfaces.go index 48cbd23a..5e6c891c 100644 --- a/http/base/rest/interfaces.go +++ b/http/base/rest/interfaces.go @@ -41,6 +41,12 @@ type ApiServer interface { Stop() } +func GetNodeVersion(cmd map[string]interface{}) map[string]interface{} { + resp := ResponsePack(berr.SUCCESS) + resp["Result"] = config.Version + return resp +} + //Node func GetGenerateBlockTime(cmd map[string]interface{}) map[string]interface{} { resp := ResponsePack(berr.SUCCESS) diff --git a/http/base/rpc/interfaces.go b/http/base/rpc/interfaces.go index 82ca6218..45f98674 100644 --- a/http/base/rpc/interfaces.go +++ b/http/base/rpc/interfaces.go @@ -298,10 +298,6 @@ func GetNodeVersion(params []interface{}) map[string]interface{} { return responseSuccess(config.Version) } -func GetSystemFee(params []interface{}) map[string]interface{} { - return responseSuccess(config.DefConfig.Common.SystemFee) -} - func GetContractState(params []interface{}) map[string]interface{} { if len(params) < 1 { return responsePack(berr.INVALID_PARAMS, nil) diff --git a/http/jsonrpc/rpc_server.go b/http/jsonrpc/rpc_server.go index 185edc53..56ac379e 100644 --- a/http/jsonrpc/rpc_server.go +++ b/http/jsonrpc/rpc_server.go @@ -45,7 +45,6 @@ func StartRPCServer() error { rpc.HandleFunc("getstorage", rpc.GetStorage) rpc.HandleFunc("getversion", rpc.GetNodeVersion) - rpc.HandleFunc("getblocksysfee", rpc.GetSystemFee) rpc.HandleFunc("getcontractstate", rpc.GetContractState) rpc.HandleFunc("getmempooltxcount", rpc.GetMemPoolTxCount) rpc.HandleFunc("getmempooltxstate", rpc.GetMemPoolTxState) diff --git a/http/restful/restful/server.go b/http/restful/restful/server.go index bd8d648d..f0f2b761 100644 --- a/http/restful/restful/server.go +++ b/http/restful/restful/server.go @@ -70,6 +70,7 @@ const ( GET_UNBOUNDONG = "/api/v1/unboundong/:addr" GET_MEMPOOL_TXCOUNT = "/api/v1/mempool/txcount" GET_MEMPOOL_TXSTATE = "/api/v1/mempool/txstate/:hash" + GET_VERSION = "/api/v1/version" POST_RAW_TX = "/api/v1/transaction" ) @@ -141,6 +142,7 @@ func (this *restServer) registryMethod() { GET_UNBOUNDONG: {name: "getunboundong", handler: rest.GetUnboundOng}, GET_MEMPOOL_TXCOUNT: {name: "getmempooltxcount", handler: rest.GetMemPoolTxCount}, GET_MEMPOOL_TXSTATE: {name: "getmempooltxstate", handler: rest.GetMemPoolTxState}, + GET_VERSION: {name: "getversion", handler: rest.GetNodeVersion}, } postMethodMap := map[string]Action{ diff --git a/http/websocket/websocket/server.go b/http/websocket/websocket/server.go index 8bcddc90..f590828e 100644 --- a/http/websocket/websocket/server.go +++ b/http/websocket/websocket/server.go @@ -195,6 +195,7 @@ func (self *WsServer) registryMethod() { "getunboundong": {handler: rest.GetUnboundOng}, "getmempooltxcount": {handler: rest.GetMemPoolTxCount}, "getmempooltxstate": {handler: rest.GetMemPoolTxState}, + "getversion": {handler: rest.GetNodeVersion}, "getsessioncount": {handler: getsessioncount}, }