From f3e1948ae9159992df9ddf5be0dda5aab2e986a8 Mon Sep 17 00:00:00 2001 From: aitorjs Date: Tue, 2 Jul 2019 16:03:52 +0200 Subject: [PATCH] v0/getmempoolinfo added :-D --- api_auth_docker/api-sample.properties | 1 + .../templates/gatekeeper/api.properties | 1 + doc/API.v0.md | 22 +++++++++++++++++++ proxy_docker/app/script/blockchainrpc.sh | 11 +++++++++- proxy_docker/app/script/requesthandler.sh | 7 ++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/api_auth_docker/api-sample.properties b/api_auth_docker/api-sample.properties index 60bd78b..9e62024 100644 --- a/api_auth_docker/api-sample.properties +++ b/api_auth_docker/api-sample.properties @@ -3,6 +3,7 @@ # Stats can: action_getblockchaininfo=stats action_installation_info=stats +action_getmempoolinfo=stats # Watcher can do what the stats can do, plus: action_watch=watcher diff --git a/cyphernodeconf_docker/templates/gatekeeper/api.properties b/cyphernodeconf_docker/templates/gatekeeper/api.properties index 25ff442..a0c82b0 100644 --- a/cyphernodeconf_docker/templates/gatekeeper/api.properties +++ b/cyphernodeconf_docker/templates/gatekeeper/api.properties @@ -6,6 +6,7 @@ # Stats can: action_getblockchaininfo=stats action_installation_info=stats +action_getmempoolinfo=stats # Watcher can: action_watch=watcher diff --git a/doc/API.v0.md b/doc/API.v0.md index 8298218..7eac098 100644 --- a/doc/API.v0.md +++ b/doc/API.v0.md @@ -292,6 +292,26 @@ When cyphernode receives a transaction confirmation (/conf endpoint) on a watche } ``` +### Get mempool information + +Returns the mempool information of the Bitcoin node. +```http +GET http://cyphernode:8888/getmempoolinfo +``` + +Proxy response: + +```json +{ + "size": 25, + "bytes": 5462, + "usage": 34736, + "maxmempool": 64000000, + "mempoolminfee": 1e-05, + "minrelaytxfee": 1e-05 +} +``` + ### Get the blockchain information (called by application) Returns the blockchain information of the Bitcoin node. Used for example by the welcome app to get syncing progression. @@ -552,6 +572,8 @@ Proxy response: } ``` + + ### Get a new Bitcoin address from spending wallet (called by application) Calls getnewaddress RPC on the spending wallet. Used to refill the spending wallet from cold wallet (ie Trezor). Will derive the default address type (set in your bitcoin.conf file, p2sh-segwit if not specified) or you can supply the address type like the following examples. diff --git a/proxy_docker/app/script/blockchainrpc.sh b/proxy_docker/app/script/blockchainrpc.sh index 07b9c88..f6dfdef 100644 --- a/proxy_docker/app/script/blockchainrpc.sh +++ b/proxy_docker/app/script/blockchainrpc.sh @@ -81,4 +81,13 @@ get_blockchain_info() local data='{"method":"getblockchaininfo"}' send_to_watcher_node "${data}" | jq ".result" return $? -} \ No newline at end of file +} + +get_mempool_info() +{ + trace "Entering get_mempool_info()..." + + local data='{"method":"getmempoolinfo"}' + send_to_watcher_node "${data}" | jq ".result" + return $? +} diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 1630973..986c3e5 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -284,6 +284,13 @@ main() response_to_client "${response}" ${?} break ;; + getmempoolinfo) + # curl GET http://192.168.111.152:8080/getmempoolinfo + trace "trace: $(get_mempool_info)" + response=$(get_mempool_info "${line}") + response_to_client "${response}" ${?} + break + ;; ln_getinfo) # GET http://192.168.111.152:8080/ln_getinfo