checkAddress API
This commit is contained in:
34
api.php
34
api.php
@@ -712,6 +712,7 @@ if ($q == "getAddress") {
|
|||||||
* @apiSuccess {number} data.transactions The number of transactions 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.mempool The number of transactions in the mempool.
|
||||||
* @apiSuccess {number} data.masternodes The number of masternodes known by the node.
|
* @apiSuccess {number} data.masternodes The number of masternodes known by the node.
|
||||||
|
* @apiSuccess {number} data.peers The number of valid peers.
|
||||||
*/
|
*/
|
||||||
$dbVersion = $db->single("SELECT val FROM config WHERE cfg='dbversion'");
|
$dbVersion = $db->single("SELECT val FROM config WHERE cfg='dbversion'");
|
||||||
$hostname = $db->single("SELECT val FROM config WHERE cfg='hostname'");
|
$hostname = $db->single("SELECT val FROM config WHERE cfg='hostname'");
|
||||||
@@ -719,7 +720,7 @@ if ($q == "getAddress") {
|
|||||||
$tr = $db->single("SELECT COUNT(1) FROM transactions");
|
$tr = $db->single("SELECT COUNT(1) FROM transactions");
|
||||||
$masternodes = $db->single("SELECT COUNT(1) FROM masternode");
|
$masternodes = $db->single("SELECT COUNT(1) FROM masternode");
|
||||||
$mempool = $db->single("SELECT COUNT(1) FROM mempool");
|
$mempool = $db->single("SELECT COUNT(1) FROM mempool");
|
||||||
|
$peers = $db->single("SELECT COUNT(1) FROM peers WHERE blacklisted<UNIX_TIMESTAMP()");
|
||||||
api_echo([
|
api_echo([
|
||||||
'hostname' => $hostname,
|
'hostname' => $hostname,
|
||||||
'version' => VERSION,
|
'version' => VERSION,
|
||||||
@@ -728,7 +729,38 @@ if ($q == "getAddress") {
|
|||||||
'transactions' => $tr,
|
'transactions' => $tr,
|
||||||
'mempool' => $mempool,
|
'mempool' => $mempool,
|
||||||
'masternodes' => $masternodes,
|
'masternodes' => $masternodes,
|
||||||
|
'peers' => $peers
|
||||||
]);
|
]);
|
||||||
|
} elseif ($q === 'checkAddress') {
|
||||||
|
/**
|
||||||
|
* @api {get} /api.php?q=checkAddress 22. checkAddress
|
||||||
|
* @apiName node-info
|
||||||
|
* @apiGroup API
|
||||||
|
* @apiDescription Checks the validity of an address.
|
||||||
|
*
|
||||||
|
* @apiParam {string} account Account id / address
|
||||||
|
* @apiParam {string} [public_key] Public key
|
||||||
|
*
|
||||||
|
* @apiSuccess {boolean} data True if the address is valid, false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$address=$data['account'];
|
||||||
|
$public_key=$data['public_key'];
|
||||||
|
$acc = new Account();
|
||||||
|
if (!$acc->valid($address)) {
|
||||||
|
api_err(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dst_b = base58_decode($address);
|
||||||
|
if (strlen($dst_b) != 64) {
|
||||||
|
api_err(false);
|
||||||
|
}
|
||||||
|
if (!empty($public_key)) {
|
||||||
|
if($acc->get_address($public_key)!=$address){
|
||||||
|
api_err(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
api_echo(true);
|
||||||
} else {
|
} else {
|
||||||
api_err("Invalid request");
|
api_err("Invalid request");
|
||||||
}
|
}
|
||||||
|
|||||||
107
doc/api_data.js
107
doc/api_data.js
@@ -1015,6 +1015,50 @@ define({ "api": [
|
|||||||
"filename": "./api.php",
|
"filename": "./api.php",
|
||||||
"groupTitle": "API"
|
"groupTitle": "API"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "get",
|
||||||
|
"url": "/api.php?q=checkAddress",
|
||||||
|
"title": "22. checkAddress",
|
||||||
|
"name": "node_info",
|
||||||
|
"group": "API",
|
||||||
|
"description": "<p>Checks the validity of an address.</p>",
|
||||||
|
"parameter": {
|
||||||
|
"fields": {
|
||||||
|
"Parameter": [
|
||||||
|
{
|
||||||
|
"group": "Parameter",
|
||||||
|
"type": "string",
|
||||||
|
"optional": false,
|
||||||
|
"field": "account",
|
||||||
|
"description": "<p>Account id / address</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Parameter",
|
||||||
|
"type": "string",
|
||||||
|
"optional": true,
|
||||||
|
"field": "public_key",
|
||||||
|
"description": "<p>Public key</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"fields": {
|
||||||
|
"Success 200": [
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "boolean",
|
||||||
|
"optional": false,
|
||||||
|
"field": "data",
|
||||||
|
"description": "<p>True if the address is valid, false otherwise.</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": "0.0.0",
|
||||||
|
"filename": "./api.php",
|
||||||
|
"groupTitle": "API"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "get",
|
"type": "get",
|
||||||
"url": "/api.php?q=node-info",
|
"url": "/api.php?q=node-info",
|
||||||
@@ -1080,6 +1124,13 @@ define({ "api": [
|
|||||||
"optional": false,
|
"optional": false,
|
||||||
"field": "data.masternodes",
|
"field": "data.masternodes",
|
||||||
"description": "<p>The number of masternodes known by the node.</p>"
|
"description": "<p>The number of masternodes known by the node.</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "number",
|
||||||
|
"optional": false,
|
||||||
|
"field": "data.peers",
|
||||||
|
"description": "<p>The number of valid peers.</p>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1301,34 +1352,6 @@ define({ "api": [
|
|||||||
"filename": "./api.php",
|
"filename": "./api.php",
|
||||||
"groupTitle": "API"
|
"groupTitle": "API"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"success": {
|
|
||||||
"fields": {
|
|
||||||
"Success 200": [
|
|
||||||
{
|
|
||||||
"group": "Success 200",
|
|
||||||
"optional": false,
|
|
||||||
"field": "varname1",
|
|
||||||
"description": "<p>No type.</p>"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group": "Success 200",
|
|
||||||
"type": "String",
|
|
||||||
"optional": false,
|
|
||||||
"field": "varname2",
|
|
||||||
"description": "<p>With type.</p>"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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",
|
"type": "php util.php",
|
||||||
"url": "balance",
|
"url": "balance",
|
||||||
@@ -1835,5 +1858,33 @@ define({ "api": [
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"filename": "./util.php",
|
"filename": "./util.php",
|
||||||
"groupTitle": "UTIL"
|
"groupTitle": "UTIL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"success": {
|
||||||
|
"fields": {
|
||||||
|
"Success 200": [
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"optional": false,
|
||||||
|
"field": "varname1",
|
||||||
|
"description": "<p>No type.</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "String",
|
||||||
|
"optional": false,
|
||||||
|
"field": "varname2",
|
||||||
|
"description": "<p>With type.</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "",
|
||||||
|
"url": "",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"filename": "./doc/main.js",
|
||||||
|
"group": "_github_node_doc_main_js",
|
||||||
|
"groupTitle": "_github_node_doc_main_js",
|
||||||
|
"name": ""
|
||||||
}
|
}
|
||||||
] });
|
] });
|
||||||
|
|||||||
@@ -1015,6 +1015,50 @@
|
|||||||
"filename": "./api.php",
|
"filename": "./api.php",
|
||||||
"groupTitle": "API"
|
"groupTitle": "API"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "get",
|
||||||
|
"url": "/api.php?q=checkAddress",
|
||||||
|
"title": "22. checkAddress",
|
||||||
|
"name": "node_info",
|
||||||
|
"group": "API",
|
||||||
|
"description": "<p>Checks the validity of an address.</p>",
|
||||||
|
"parameter": {
|
||||||
|
"fields": {
|
||||||
|
"Parameter": [
|
||||||
|
{
|
||||||
|
"group": "Parameter",
|
||||||
|
"type": "string",
|
||||||
|
"optional": false,
|
||||||
|
"field": "account",
|
||||||
|
"description": "<p>Account id / address</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Parameter",
|
||||||
|
"type": "string",
|
||||||
|
"optional": true,
|
||||||
|
"field": "public_key",
|
||||||
|
"description": "<p>Public key</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"fields": {
|
||||||
|
"Success 200": [
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "boolean",
|
||||||
|
"optional": false,
|
||||||
|
"field": "data",
|
||||||
|
"description": "<p>True if the address is valid, false otherwise.</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": "0.0.0",
|
||||||
|
"filename": "./api.php",
|
||||||
|
"groupTitle": "API"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "get",
|
"type": "get",
|
||||||
"url": "/api.php?q=node-info",
|
"url": "/api.php?q=node-info",
|
||||||
@@ -1080,6 +1124,13 @@
|
|||||||
"optional": false,
|
"optional": false,
|
||||||
"field": "data.masternodes",
|
"field": "data.masternodes",
|
||||||
"description": "<p>The number of masternodes known by the node.</p>"
|
"description": "<p>The number of masternodes known by the node.</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "number",
|
||||||
|
"optional": false,
|
||||||
|
"field": "data.peers",
|
||||||
|
"description": "<p>The number of valid peers.</p>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1301,34 +1352,6 @@
|
|||||||
"filename": "./api.php",
|
"filename": "./api.php",
|
||||||
"groupTitle": "API"
|
"groupTitle": "API"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"success": {
|
|
||||||
"fields": {
|
|
||||||
"Success 200": [
|
|
||||||
{
|
|
||||||
"group": "Success 200",
|
|
||||||
"optional": false,
|
|
||||||
"field": "varname1",
|
|
||||||
"description": "<p>No type.</p>"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group": "Success 200",
|
|
||||||
"type": "String",
|
|
||||||
"optional": false,
|
|
||||||
"field": "varname2",
|
|
||||||
"description": "<p>With type.</p>"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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",
|
"type": "php util.php",
|
||||||
"url": "balance",
|
"url": "balance",
|
||||||
@@ -1835,5 +1858,33 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"filename": "./util.php",
|
"filename": "./util.php",
|
||||||
"groupTitle": "UTIL"
|
"groupTitle": "UTIL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"success": {
|
||||||
|
"fields": {
|
||||||
|
"Success 200": [
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"optional": false,
|
||||||
|
"field": "varname1",
|
||||||
|
"description": "<p>No type.</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Success 200",
|
||||||
|
"type": "String",
|
||||||
|
"optional": false,
|
||||||
|
"field": "varname2",
|
||||||
|
"description": "<p>With type.</p>"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "",
|
||||||
|
"url": "",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"filename": "./doc/main.js",
|
||||||
|
"group": "_github_node_doc_main_js",
|
||||||
|
"groupTitle": "_github_node_doc_main_js",
|
||||||
|
"name": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
define({
|
define({
|
||||||
"name": "Arionum Node",
|
"name": "",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "The Arionum Node API and utility documentation.",
|
"description": "",
|
||||||
"title": "Arionum Node",
|
|
||||||
"sampleUrl": false,
|
"sampleUrl": false,
|
||||||
"defaultVersion": "0.0.0",
|
"defaultVersion": "0.0.0",
|
||||||
"apidoc": "0.3.0",
|
"apidoc": "0.3.0",
|
||||||
"generator": {
|
"generator": {
|
||||||
"name": "apidoc",
|
"name": "apidoc",
|
||||||
"time": "2018-10-12T11:08:47.065Z",
|
"time": "2018-11-05T09:41:33.896Z",
|
||||||
"url": "http://apidocjs.com",
|
"url": "http://apidocjs.com",
|
||||||
"version": "0.17.6"
|
"version": "0.17.6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Arionum Node",
|
"name": "",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "The Arionum Node API and utility documentation.",
|
"description": "",
|
||||||
"title": "Arionum Node",
|
|
||||||
"sampleUrl": false,
|
"sampleUrl": false,
|
||||||
"defaultVersion": "0.0.0",
|
"defaultVersion": "0.0.0",
|
||||||
"apidoc": "0.3.0",
|
"apidoc": "0.3.0",
|
||||||
"generator": {
|
"generator": {
|
||||||
"name": "apidoc",
|
"name": "apidoc",
|
||||||
"time": "2018-10-12T11:08:47.065Z",
|
"time": "2018-11-05T09:41:33.896Z",
|
||||||
"url": "http://apidocjs.com",
|
"url": "http://apidocjs.com",
|
||||||
"version": "0.17.6"
|
"version": "0.17.6"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user