From f45837892cb08a2e04d7f9f85589d2aaa240459f Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Tue, 9 Oct 2018 20:39:55 -0700 Subject: [PATCH 01/33] Update CHANGELOG.rst --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ca0ca8e61..42557058f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ All notable changes to this project are documented in this file. ------------------- - Add ExtendedJsonRpcApi, Add ``getnodestate`` RPC extended method, Add ``gettxhistory`` RPC extended method - Fix return types of ``claimGas`` function. +- Update docs to include ``ExtendedJsonRpcApi`` [0.8.1] 2018-10-06 ------------------ From 719a6fe0c49a7fda07b015078cfb81ccf98d93ad Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Tue, 9 Oct 2018 20:51:44 -0700 Subject: [PATCH 02/33] Update Readme.rst - fix typo --- docs/Readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Readme.rst b/docs/Readme.rst index 6a1ae3d29..aea3b7e83 100644 --- a/docs/Readme.rst +++ b/docs/Readme.rst @@ -7,7 +7,7 @@ Guidelines ---------- When contributing please note the following: -1. NEO-Python Docs use the sphinx module to build https://neo-python.readthedocs.io/en/latest/. So, make sure every docucment you add uses reStructuredText (e.g. .rst). +1. NEO-Python Docs use the sphinx module to build https://neo-python.readthedocs.io/en/latest/. So, make sure every document you add uses reStructuredText (e.g. .rst). 2. After creating your document, be sure to update the ``toctree`` in index.rst. **Failing to do so will result in your document missing from the readthedocs website.** From 23ab95f482bd8a4d1b775abc996f5d635ccb7155 Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Tue, 9 Oct 2018 21:39:38 -0700 Subject: [PATCH 03/33] Update basicusage.rst - update help display to show `--extended-rpc` - update formatting --- docs/source/basicusage.rst | 70 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/docs/source/basicusage.rst b/docs/source/basicusage.rst index b491d680a..b256187e1 100644 --- a/docs/source/basicusage.rst +++ b/docs/source/basicusage.rst @@ -1,11 +1,11 @@ Basic Usage ------------ +=========== There are two main ways to use neo-python: ``np-prompt`` and running just the node with custom code. np-prompt -""""""""" +--------- Start np-prompt on TestNet: @@ -39,15 +39,14 @@ Show help with all available arguments: Node with custom code -""""""""""""""""""""" +---------------------- Take a look at the examples in the ``/examples`` directory: https://github.com/CityOfZion/neo-python/tree/development/examples See also the sections about "Settings and Logging" and "Interacting with Smart Contracts". - API server (JSON and/or REST) -"""""""""""""""""""""""""""""" +============================= Start JSON and REST API Server on Mainnet: @@ -55,7 +54,7 @@ Start JSON and REST API Server on Mainnet: $ np-api-server --mainnet --port-rpc 10332 --port-rest 80 -Example notifications plus help with all available arguments: +Example notifications: :: @@ -67,45 +66,55 @@ Example notifications plus help with all available arguments: [I 180315 09:27:09 _observer:131] Starting factory [I 180315 09:27:09 np-api-server:11] Starting REST api server on http://0.0.0.0:8088 - # view help - $ np-api-server -h - usage: np-api-server [-h] +View help with all available arguments: + +:: + + $ np-api-server -h + usage: np-api-server [-h] (--mainnet | --testnet | --privnet | --coznet | --config CONFIG) [--port-rpc PORT_RPC] [--port-rest PORT_REST] [--logfile LOGFILE] [--syslog] [--syslog-local [0-7]] [--disable-stderr] [--datadir DATADIR] [--maxpeers MAXPEERS] [--wallet WALLET] [--host HOST] + [--extended-rpc] optional arguments: - -h, --help show this help message and exit - --datadir DATADIR Absolute path to use for database directories - --maxpeers MAXPEERS Max peers to use for P2P Joining - --wallet WALLET Open wallet. Will allow you to use methods that - require an open wallet - --host HOST Hostname ( for example 127.0.0.1) + -h, --help show this help message and exit + --datadir DATADIR Absolute path to use for database directories + --maxpeers MAXPEERS Max peers to use for P2P Joining + --wallet WALLET Open wallet. Will allow you to use methods that + require an open wallet + --host HOST Hostname ( for example 127.0.0.1) + --extended-rpc Use extended json-rpc api Network options: - --mainnet Use MainNet - --testnet Use TestNet - --privnet Use PrivNet - --coznet Use CozNet - --config CONFIG Use a specific config file + --mainnet Use MainNet + --testnet Use TestNet + --privnet Use PrivNet + --coznet Use CozNet + --config CONFIG Use a specific config file Mode(s): - --port-rpc PORT_RPC port to use for the json-rpc api (eg. 10332) - --port-rest PORT_REST port to use for the rest api (eg. 80) + --port-rpc PORT_RPC port to use for the json-rpc api (eg. 10332) + --port-rest PORT_REST + port to use for the rest api (eg. 80) Logging options: - --logfile LOGFILE Logfile - --syslog Log to syslog instead of to log file ('user' is the - default facility) - --syslog-local [0-7] Log to a local syslog facility instead of 'user'. - Value must be between 0 and 7 (e.g. 0 for 'local0'). - --disable-stderr Disable stderr logger + --logfile LOGFILE Logfile + --syslog Log to syslog instead of to log file ('user' is the + default facility) + --syslog-local [0-7] Log to a local syslog facility instead of 'user'. + Value must be between 0 and 7 (e.g. 0 for 'local0'). + --disable-stderr Disable stderr logger + +Running Extended Json-RPC Api Server +------------------------------------ +Using the ``--extended-rpc`` arg will start your server with additional methods from ExtendedJsonRpcApi in addition to the normal JsonRpcApi methods. All original functionality is retained with the added functionality from ExtendedJsonRpcApi. Port Description -"""""""""""""""""""""""""""""" +---------------- If you want an external program to access your API server, an open firewall port is required. The following is a port description that can be set to fully open or open-on-demand. @@ -123,9 +132,10 @@ If you want an external program to access your API server, an open firewall port - 10332 - 20332 +For P2P and WebSocket information see `NEO-Python Seedlist `_. Running an API Server using Windows WSL (Ubuntu) -"""""""""""""""""""""""""""""""""""""""""""""""" +------------------------------------------------ If you are running neo-python on Windows WSL (Ubuntu), opening the respective ports on your router is not enough. You will need to add a new inbound rule to your Windows Firewall as described `here `_. From 76564e47493e17a614f527f6209c7ad8e1cfe258 Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Tue, 9 Oct 2018 21:59:02 -0700 Subject: [PATCH 04/33] Update basicusage.rst - update formatting, introduce a new header for visibility, and modify wording --- docs/source/basicusage.rst | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/source/basicusage.rst b/docs/source/basicusage.rst index b256187e1..ce9caf4cc 100644 --- a/docs/source/basicusage.rst +++ b/docs/source/basicusage.rst @@ -1,11 +1,14 @@ Basic Usage =========== -There are two main ways to use neo-python: ``np-prompt`` and running just the node with custom +Introduction +------------ + +There are two main ways to interface with neo-python: ``np-prompt`` and running just the node with custom code. np-prompt ---------- +""""""""" Start np-prompt on TestNet: @@ -39,14 +42,16 @@ Show help with all available arguments: Node with custom code ----------------------- +""""""""""""""""""""" Take a look at the examples in the ``/examples`` directory: https://github.com/CityOfZion/neo-python/tree/development/examples See also the sections about "Settings and Logging" and "Interacting with Smart Contracts". API server (JSON and/or REST) -============================= +----------------------------- + +Each neo-python node is capable of providing an API interface, which can be used to query the NEO Blockchain. The API interface is provided via JSON-RPC, and the underlying protocol uses HTTP/HTTPS for communication. Start JSON and REST API Server on Mainnet: @@ -109,12 +114,12 @@ View help with all available arguments: --disable-stderr Disable stderr logger Running Extended Json-RPC Api Server ------------------------------------- +"""""""""""""""""""""""""""""""""""" Using the ``--extended-rpc`` arg will start your server with additional methods from ExtendedJsonRpcApi in addition to the normal JsonRpcApi methods. All original functionality is retained with the added functionality from ExtendedJsonRpcApi. Port Description ----------------- +"""""""""""""""" If you want an external program to access your API server, an open firewall port is required. The following is a port description that can be set to fully open or open-on-demand. @@ -135,7 +140,7 @@ If you want an external program to access your API server, an open firewall port For P2P and WebSocket information see `NEO-Python Seedlist `_. Running an API Server using Windows WSL (Ubuntu) ------------------------------------------------- +"""""""""""""""""""""""""""""""""""""""""""""""" If you are running neo-python on Windows WSL (Ubuntu), opening the respective ports on your router is not enough. You will need to add a new inbound rule to your Windows Firewall as described `here `_. From 4adc41a1b8184731da92a92253809ca26328adb3 Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Tue, 9 Oct 2018 23:19:10 -0700 Subject: [PATCH 05/33] Update basicusage.rst - clarify interface methods for neo-python API servers --- docs/source/basicusage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/basicusage.rst b/docs/source/basicusage.rst index ce9caf4cc..5f9b11754 100644 --- a/docs/source/basicusage.rst +++ b/docs/source/basicusage.rst @@ -51,7 +51,7 @@ See also the sections about "Settings and Logging" and "Interacting with Smart C API server (JSON and/or REST) ----------------------------- -Each neo-python node is capable of providing an API interface, which can be used to query the NEO Blockchain. The API interface is provided via JSON-RPC, and the underlying protocol uses HTTP/HTTPS for communication. +Each neo-python node is capable of providing an API interface, which can be used to query the NEO Blockchain. The API interface is provided via JSON-RPC or REST, and the underlying protocol uses HTTP/HTTPS for communication. JSON-RPC and REST API servers may be run simultaneously. Start JSON and REST API Server on Mainnet: From 6727c3a50b57eb70e71dd74fbbf676053ab849e9 Mon Sep 17 00:00:00 2001 From: jseagrave21 <40873301+jseagrave21@users.noreply.github.com> Date: Wed, 10 Oct 2018 00:31:51 -0700 Subject: [PATCH 06/33] Create Api_Server.rst - Include brief description and usage data - Include default JSON-RPC command list - Include extended JSON-RPC command list - Include POST request examples - Include GET request example --- docs/source/Api_Server.rst | 277 +++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 docs/source/Api_Server.rst diff --git a/docs/source/Api_Server.rst b/docs/source/Api_Server.rst new file mode 100644 index 000000000..56d75917d --- /dev/null +++ b/docs/source/Api_Server.rst @@ -0,0 +1,277 @@ +API Server +=========== + +The neo-python API server provides an API interface, which can be used to query the NEO Blockchain via JSON-RPC or REST. + +Start JSON and REST API Server on Mainnet: + +:: + + $ np-api-server --mainnet --port-rpc 10332 --port-rest 80 + +Usage +----- + +:: + + $ np-api-server -h + usage: np-api-server [-h] + (--mainnet | --testnet | --privnet | --coznet | --config CONFIG) + [--port-rpc PORT_RPC] [--port-rest PORT_REST] + [--logfile LOGFILE] [--syslog] [--syslog-local [0-7]] + [--disable-stderr] [--datadir DATADIR] + [--maxpeers MAXPEERS] [--wallet WALLET] [--host HOST] + [--extended-rpc] + + optional arguments: + -h, --help show this help message and exit + --datadir DATADIR Absolute path to use for database directories + --maxpeers MAXPEERS Max peers to use for P2P Joining + --wallet WALLET Open wallet. Will allow you to use methods that + require an open wallet + --host HOST Hostname ( for example 127.0.0.1) + --extended-rpc Use extended json-rpc api + + Network options: + --mainnet Use MainNet + --testnet Use TestNet + --privnet Use PrivNet + --coznet Use CozNet + --config CONFIG Use a specific config file + + Mode(s): + --port-rpc PORT_RPC port to use for the json-rpc api (eg. 10332) + --port-rest PORT_REST + port to use for the rest api (eg. 80) + + Logging options: + --logfile LOGFILE Logfile + --syslog Log to syslog instead of to log file ('user' is the + default facility) + --syslog-local [0-7] Log to a local syslog facility instead of 'user'. + Value must be between 0 and 7 (e.g. 0 for 'local0'). + --disable-stderr Disable stderr logger + +Default JSON-RPC Command List +----------------------------- + +.. list-table:: + :widths: 20 20 40 10 + :header-rows: 1 + + * - Command + - Reference + - Explanations + - Comments + * - getaccountstate + -
+ - Checks account asset information according to account address + - + * - getassetstate + - + - Queries asset information according to the specified asset number + - + * - getbalance + - + - Returns the balance of the corresponding asset in the wallet according to the specified asset number. + - Need to open the wallet + * - getbestblockhash + - + - Gets the hash of the tallest block in the main chain + - + * - getblock + - | + | [verbose=0] + | [json=1] + - Returns the corresponding block information according to the specified hash value or index + - + * - getblockcount + - + - Gets the number of blocks in the main chain + - + * - getblockhash + - + - Returns the hash value of the corresponding block based on the specified index + - + * - getblocksysfee + - + - Returns the system fees before the block according to the specified index + - + * - getconnectioncount + - + - Gets the current number of connections for the node + - + * - getcontractstate + - + - Returns information about the contract based on the specified script hash + - + * - getnewaddress + - + - Creates a new address + - Need to open the wallet + * - getrawmempool + - + - Gets a list of unconfirmed transactions in memory + - + * - getrawtransaction + - | + | [verbose=0] + | [json=1] + - Returns the corresponding transaction information based on the specified hash value + - + * - getstorage + - + - Returns the stored value based on the contract script hash and key + - + * - gettxout + - + - Returns the corresponding transaction output (change) information based on the specified hash and index + - + * - getpeers + - + - Gets a list of nodes that are currently connected/disconnected by this node + - + * - getversion + - + - Gets version information of this node + - + * - getwalletheight + - + - Gets the current wallet index height. + - Need to open the wallet + * - invoke + - + - Invokes a smart contract at specified script hash with the given parameters + - + * - invokefunction + - + - Invokes a smart contract at specified script hash, passing in an operation and its params + - + * - invokescript + -