From 6383aade6e8fde431ea585502a30aef79b3138ff Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 11:35:57 +0100 Subject: [PATCH 1/6] Fix doc numbering typo for getAlias --- api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.php b/api.php index da6459d..d8e4cee 100755 --- a/api.php +++ b/api.php @@ -651,7 +651,7 @@ if ($q == "getAddress") { api_echo(["masternodes"=>$res, "hash"=>md5(json_encode($res))]); } elseif ($q == "getAlias") { /** - * @api {get} /api.php?q=getAlias 189. getAlias + * @api {get} /api.php?q=getAlias 19. getAlias * @apiName getAlias * @apiGroup API * @apiDescription Returns the alias of an account From 3f42a53991b8a44b697bb9cae6f4d10033ca9777 Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 11:38:20 +0100 Subject: [PATCH 2/6] Update the formatting of the sanity API code --- api.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/api.php b/api.php index d8e4cee..2743c64 100755 --- a/api.php +++ b/api.php @@ -678,14 +678,12 @@ if ($q == "getAddress") { $account = san($account); api_echo($acc->account2alias($account)); -} elseif ($q=="sanity"){ - $sanity=false; - if(file_exists("tmp/sanity-lock")) { - $sanity=true; - } - $last_sanity=$db->single("SELECT val FROM config WHERE cfg='sanity_last'"); - $sanity_sync=$db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); - api_echo(["sanity_running"=>$sanity,"last_sanity"=>$last_sanity, "sanity_sync"=>$sanity_sync]); +} elseif ($q === 'sanity') { + $sanity = file_exists(__DIR__.'/tmp/sanity-lock'); + + $lastSanity = $db->single("SELECT val FROM config WHERE cfg='sanity_last'"); + $sanitySync = $db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); + api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]); } elseif ($q=="node-info"){ $dbversion=$db->single("SELECT val FROM config WHERE cfg='dbversion'"); $hostname=$db->single("SELECT val FROM config WHERE cfg='hostname'"); From c8a8d3b9d006c4b14a625949e4eeb465e2b62a87 Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 11:55:24 +0100 Subject: [PATCH 3/6] Add apiDoc comments for the sanity endpoint --- api.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/api.php b/api.php index 2743c64..8dccc6a 100755 --- a/api.php +++ b/api.php @@ -423,8 +423,8 @@ if ($q == "getAddress") { api_err("Invalid destination alias"); } } - - + + $public_key = san($data['public_key']); if (!$acc->valid_key($public_key)) { @@ -454,7 +454,7 @@ if ($q == "getAddress") { if ($date > time() + 86400) { api_err("Invalid Date"); } - + $message=$data['message']; if (strlen($message) > 128) { api_err("The message must be less than 128 chars"); @@ -472,7 +472,7 @@ if ($q == "getAddress") { if ($val < 0.00000001) { api_err("Invalid value"); } - + // set alias if ($version==3) { $fee=10; @@ -632,7 +632,7 @@ if ($q == "getAddress") { $public_key=san($data['public_key']); $signature=san($data['signature']); $data=$data['data']; - + api_echo(ec_verify($data, $signature, $public_key)); } elseif ($q == "masternodes") { /** @@ -662,7 +662,7 @@ if ($q == "getAddress") { * * @apiSuccess {string} data alias */ - + $public_key = $data['public_key']; $account = $data['account']; if (!empty($public_key) && strlen($public_key) < 32) { @@ -671,18 +671,29 @@ if ($q == "getAddress") { if (!empty($public_key)) { $account = $acc->get_address($public_key); } - + if (empty($account)) { api_err("Invalid account id"); } $account = san($account); - + api_echo($acc->account2alias($account)); } elseif ($q === 'sanity') { + /** + * @api {get} /api.php?q=sanity 20. sanity + * @apiName sanity + * @apiGroup API + * @apiDescription Returns details about the node's sanity process. + * + * @apiSuccess {object} data A collection of data about the sanity process. + * @apiSuccess {boolean} data.sanity_running Whether the sanity process is currently running. + * @apiSuccess {number} data.last_sanity The timestamp for the last time the sanity process was run. + * @apiSuccess {boolean} data.sanity_sync Whether the sanity process is currently synchronising. + */ $sanity = file_exists(__DIR__.'/tmp/sanity-lock'); - $lastSanity = $db->single("SELECT val FROM config WHERE cfg='sanity_last'"); - $sanitySync = $db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); + $lastSanity = (int)$db->single("SELECT val FROM config WHERE cfg='sanity_last'"); + $sanitySync = (bool)$db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]); } elseif ($q=="node-info"){ $dbversion=$db->single("SELECT val FROM config WHERE cfg='dbversion'"); @@ -692,7 +703,7 @@ if ($q == "getAddress") { $mns=$db->single("SELECT COUNT(1) FROM masternode"); $mempool=$db->single("SELECT COUNT(1) FROM mempool"); api_echo(["hostname"=>$hostname, "version"=>VERSION,"dbversion"=>$dbversion, "accounts"=>$acc, "transactions"=>$tr, "mempool"=>$mempool, "masternodes"=>$mns]); - + } else { api_err("Invalid request"); } From e389988bdafaf24cd93b28f8fabaae02e768734e Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 11:58:08 +0100 Subject: [PATCH 4/6] Update the formatting of the node-info API code --- api.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/api.php b/api.php index 8dccc6a..8e7d875 100755 --- a/api.php +++ b/api.php @@ -695,15 +695,23 @@ if ($q == "getAddress") { $lastSanity = (int)$db->single("SELECT val FROM config WHERE cfg='sanity_last'"); $sanitySync = (bool)$db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]); -} elseif ($q=="node-info"){ - $dbversion=$db->single("SELECT val FROM config WHERE cfg='dbversion'"); - $hostname=$db->single("SELECT val FROM config WHERE cfg='hostname'"); - $acc=$db->single("SELECT COUNT(1) FROM accounts"); - $tr=$db->single("SELECT COUNT(1) FROM transactions"); - $mns=$db->single("SELECT COUNT(1) FROM masternode"); - $mempool=$db->single("SELECT COUNT(1) FROM mempool"); - api_echo(["hostname"=>$hostname, "version"=>VERSION,"dbversion"=>$dbversion, "accounts"=>$acc, "transactions"=>$tr, "mempool"=>$mempool, "masternodes"=>$mns]); +} elseif ($q === 'node-info') { + $dbVersion = $db->single("SELECT val FROM config WHERE cfg='dbversion'"); + $hostname = $db->single("SELECT val FROM config WHERE cfg='hostname'"); + $acc = $db->single("SELECT COUNT(1) FROM accounts"); + $tr = $db->single("SELECT COUNT(1) FROM transactions"); + $masternodes = $db->single("SELECT COUNT(1) FROM masternode"); + $mempool = $db->single("SELECT COUNT(1) FROM mempool"); + api_echo([ + 'hostname' => $hostname, + 'version' => VERSION, + 'dbversion' => $dbVersion, + 'accounts' => $acc, + 'transactions' => $tr, + 'mempool' => $mempool, + 'masternodes' => $masternodes, + ]); } else { api_err("Invalid request"); } From d6c6d3420ed1b6b6476f4bd2d87a984d3f7a48ed Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 12:01:56 +0100 Subject: [PATCH 5/6] Add apiDoc comments for the node-info endpoint --- api.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api.php b/api.php index 8e7d875..14fa27f 100755 --- a/api.php +++ b/api.php @@ -696,6 +696,21 @@ if ($q == "getAddress") { $sanitySync = (bool)$db->single("SELECT val FROM config WHERE cfg='sanity_sync'"); api_echo(['sanity_running' => $sanity, 'last_sanity' => $lastSanity, 'sanity_sync' => $sanitySync]); } elseif ($q === 'node-info') { + /** + * @api {get} /api.php?q=node-info 21. node-info + * @apiName node-info + * @apiGroup API + * @apiDescription Returns details about the node. + * + * @apiSuccess {object} data A collection of data about the node. + * @apiSuccess {string} data.hostname The hostname of the node. + * @apiSuccess {string} data.version The current version of the node. + * @apiSuccess {string} data.dbversion The database schema version for the node. + * @apiSuccess {number} data.accounts The number of accounts known by the node. + * @apiSuccess {number} data.transactions The number of transactions known by the node. + * @apiSuccess {number} data.mempool The number of transactions in the mempool. + * @apiSuccess {number} data.masternodes The number of masternodes known by the node. + */ $dbVersion = $db->single("SELECT val FROM config WHERE cfg='dbversion'"); $hostname = $db->single("SELECT val FROM config WHERE cfg='hostname'"); $acc = $db->single("SELECT COUNT(1) FROM accounts"); From 5fbb3c3ac26a4f74a15410c298297d97e66182ea Mon Sep 17 00:00:00 2001 From: pxgamer Date: Fri, 12 Oct 2018 12:11:42 +0100 Subject: [PATCH 6/6] Update the API documentation output --- doc/api_data.js | 176 ++++++++++++++++++++++++++++++++++++------- doc/api_data.json | 176 ++++++++++++++++++++++++++++++++++++------- doc/api_project.js | 7 +- doc/api_project.json | 7 +- 4 files changed, 302 insertions(+), 64 deletions(-) diff --git a/doc/api_data.js b/doc/api_data.js index e2767bc..754125c 100644 --- a/doc/api_data.js +++ b/doc/api_data.js @@ -303,7 +303,7 @@ define({ "api": [ { "type": "get", "url": "/api.php?q=getAlias", - "title": "189. getAlias", + "title": "19. getAlias", "name": "getAlias", "group": "API", "description": "

Returns the alias of an account

", @@ -1015,6 +1015,79 @@ define({ "api": [ "filename": "./api.php", "groupTitle": "API" }, + { + "type": "get", + "url": "/api.php?q=node-info", + "title": "21. node-info", + "name": "node_info", + "group": "API", + "description": "

Returns details about the node.

", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "object", + "optional": false, + "field": "data", + "description": "

A collection of data about the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.hostname", + "description": "

The hostname of the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.version", + "description": "

The current version of the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.dbversion", + "description": "

The database schema version for the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.accounts", + "description": "

The number of accounts known by the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.transactions", + "description": "

The number of transactions known by the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.mempool", + "description": "

The number of transactions in the mempool.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.masternodes", + "description": "

The number of masternodes known by the node.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "./api.php", + "groupTitle": "API" + }, { "type": "get", "url": "/api.php?q=randomNumber", @@ -1073,6 +1146,51 @@ define({ "api": [ "filename": "./api.php", "groupTitle": "API" }, + { + "type": "get", + "url": "/api.php?q=sanity", + "title": "20. sanity", + "name": "sanity", + "group": "API", + "description": "

Returns details about the node's sanity process.

", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "object", + "optional": false, + "field": "data", + "description": "

A collection of data about the sanity process.

" + }, + { + "group": "Success 200", + "type": "boolean", + "optional": false, + "field": "data.sanity_running", + "description": "

Whether the sanity process is currently running.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.last_sanity", + "description": "

The timestamp for the last time the sanity process was run.

" + }, + { + "group": "Success 200", + "type": "boolean", + "optional": false, + "field": "data.sanity_sync", + "description": "

Whether the sanity process is currently synchronising.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "./api.php", + "groupTitle": "API" + }, { "type": "get", "url": "/api.php?q=send", @@ -1183,6 +1301,34 @@ define({ "api": [ "filename": "./api.php", "groupTitle": "API" }, + { + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "optional": false, + "field": "varname1", + "description": "

No type.

" + }, + { + "group": "Success 200", + "type": "String", + "optional": false, + "field": "varname2", + "description": "

With type.

" + } + ] + } + }, + "type": "", + "url": "", + "version": "0.0.0", + "filename": "./doc/main.js", + "group": "C__Users_owen_voke_Documents_GitHub_php_arionum_node_doc_main_js", + "groupTitle": "C__Users_owen_voke_Documents_GitHub_php_arionum_node_doc_main_js", + "name": "" + }, { "type": "php util.php", "url": "balance", @@ -1689,33 +1835,5 @@ define({ "api": [ "version": "0.0.0", "filename": "./util.php", "groupTitle": "UTIL" - }, - { - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "optional": false, - "field": "varname1", - "description": "

No type.

" - }, - { - "group": "Success 200", - "type": "String", - "optional": false, - "field": "varname2", - "description": "

With type.

" - } - ] - } - }, - "type": "", - "url": "", - "version": "0.0.0", - "filename": "./doc/main.js", - "group": "_github_node_doc_main_js", - "groupTitle": "_github_node_doc_main_js", - "name": "" } ] }); diff --git a/doc/api_data.json b/doc/api_data.json index 52e4c8c..c5a722d 100644 --- a/doc/api_data.json +++ b/doc/api_data.json @@ -303,7 +303,7 @@ { "type": "get", "url": "/api.php?q=getAlias", - "title": "189. getAlias", + "title": "19. getAlias", "name": "getAlias", "group": "API", "description": "

Returns the alias of an account

", @@ -1015,6 +1015,79 @@ "filename": "./api.php", "groupTitle": "API" }, + { + "type": "get", + "url": "/api.php?q=node-info", + "title": "21. node-info", + "name": "node_info", + "group": "API", + "description": "

Returns details about the node.

", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "object", + "optional": false, + "field": "data", + "description": "

A collection of data about the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.hostname", + "description": "

The hostname of the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.version", + "description": "

The current version of the node.

" + }, + { + "group": "Success 200", + "type": "string", + "optional": false, + "field": "data.dbversion", + "description": "

The database schema version for the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.accounts", + "description": "

The number of accounts known by the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.transactions", + "description": "

The number of transactions known by the node.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.mempool", + "description": "

The number of transactions in the mempool.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.masternodes", + "description": "

The number of masternodes known by the node.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "./api.php", + "groupTitle": "API" + }, { "type": "get", "url": "/api.php?q=randomNumber", @@ -1073,6 +1146,51 @@ "filename": "./api.php", "groupTitle": "API" }, + { + "type": "get", + "url": "/api.php?q=sanity", + "title": "20. sanity", + "name": "sanity", + "group": "API", + "description": "

Returns details about the node's sanity process.

", + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "type": "object", + "optional": false, + "field": "data", + "description": "

A collection of data about the sanity process.

" + }, + { + "group": "Success 200", + "type": "boolean", + "optional": false, + "field": "data.sanity_running", + "description": "

Whether the sanity process is currently running.

" + }, + { + "group": "Success 200", + "type": "number", + "optional": false, + "field": "data.last_sanity", + "description": "

The timestamp for the last time the sanity process was run.

" + }, + { + "group": "Success 200", + "type": "boolean", + "optional": false, + "field": "data.sanity_sync", + "description": "

Whether the sanity process is currently synchronising.

" + } + ] + } + }, + "version": "0.0.0", + "filename": "./api.php", + "groupTitle": "API" + }, { "type": "get", "url": "/api.php?q=send", @@ -1183,6 +1301,34 @@ "filename": "./api.php", "groupTitle": "API" }, + { + "success": { + "fields": { + "Success 200": [ + { + "group": "Success 200", + "optional": false, + "field": "varname1", + "description": "

No type.

" + }, + { + "group": "Success 200", + "type": "String", + "optional": false, + "field": "varname2", + "description": "

With type.

" + } + ] + } + }, + "type": "", + "url": "", + "version": "0.0.0", + "filename": "./doc/main.js", + "group": "C__Users_owen_voke_Documents_GitHub_php_arionum_node_doc_main_js", + "groupTitle": "C__Users_owen_voke_Documents_GitHub_php_arionum_node_doc_main_js", + "name": "" + }, { "type": "php util.php", "url": "balance", @@ -1689,33 +1835,5 @@ "version": "0.0.0", "filename": "./util.php", "groupTitle": "UTIL" - }, - { - "success": { - "fields": { - "Success 200": [ - { - "group": "Success 200", - "optional": false, - "field": "varname1", - "description": "

No type.

" - }, - { - "group": "Success 200", - "type": "String", - "optional": false, - "field": "varname2", - "description": "

With type.

" - } - ] - } - }, - "type": "", - "url": "", - "version": "0.0.0", - "filename": "./doc/main.js", - "group": "_github_node_doc_main_js", - "groupTitle": "_github_node_doc_main_js", - "name": "" } ] diff --git a/doc/api_project.js b/doc/api_project.js index b16aaa2..7485b95 100644 --- a/doc/api_project.js +++ b/doc/api_project.js @@ -1,13 +1,14 @@ define({ - "name": "", + "name": "Arionum Node", "version": "0.0.0", - "description": "", + "description": "The Arionum Node API and utility documentation.", + "title": "Arionum Node", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2018-08-05T21:17:14.214Z", + "time": "2018-10-12T11:08:47.065Z", "url": "http://apidocjs.com", "version": "0.17.6" } diff --git a/doc/api_project.json b/doc/api_project.json index 6ee5d3e..b9f6676 100644 --- a/doc/api_project.json +++ b/doc/api_project.json @@ -1,13 +1,14 @@ { - "name": "", + "name": "Arionum Node", "version": "0.0.0", - "description": "", + "description": "The Arionum Node API and utility documentation.", + "title": "Arionum Node", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2018-08-05T21:17:14.214Z", + "time": "2018-10-12T11:08:47.065Z", "url": "http://apidocjs.com", "version": "0.17.6" }