verifymessage added to api cmd settings

This commit is contained in:
joeuhren
2020-12-21 18:12:40 -07:00
parent 4a084cdfe1
commit dfbd2d9046
6 changed files with 53 additions and 17 deletions
+4
View File
@@ -42,6 +42,10 @@ This project is a fork of [Ciquidus Explorer](https://github.com/suprnurd/ciquid
- **getvotelist:** Returns an object with details regarding the current vote list
- **getmasternodecount:** Returns a json object containing the total number of masternodes on the network
- **getmasternodelist:** Returns a json array containing status information for all masternodes on the network
- **verifymessage:** Verify a signed message. Must accept the following arguments:
- **address:** The wallet address to use for the signature.
- **signature:** The signature provided by the signer in base 64 encoding.
- **message:** The message that was signed.
### See it in action
+10 -15
View File
@@ -286,23 +286,18 @@ app.use('/ext/getaddresstxs/:address/:start/:length', function(req,res) {
});
});
app.post('/address/:hash/claim', function(req, res){
var address = req.body.address;
var signature = req.body.signature;
var message = req.body.message;
request({ url: 'http://127.0.0.1:' + settings.port + '/api/verifymessage?address='+address+ '&signature='+ signature + '&message=' + message, method: 'GET'}, function(error, response, body) {
if (body == 'There was an error. Check your console.')
res.json({"status": "failed", "error": true, "message": body});
else if (body == "false") {
res.json({"status": "failed", "error": true, "message": error});
} else if(body == "true") {
db.update_label(address, message, function() {
res.json({"status": "success"});
app.post('/address/:hash/claim', function(req, res) {
lib.verify_message(req.body.address, req.body.signature, req.body.message, function(body) {
if (body == false) {
res.json({'status': 'failed', 'error': true, 'message': 'Invalid signature'});
} else if (body == true) {
db.update_label(req.body.address, req.body.message, function() {
res.json({'status': 'success'});
});
}
} else
res.json({'status': 'failed', 'error': true, 'message': 'There was an error. Check your console.'});
});
})
});
app.use('/ext/connections', function(req,res){
db.get_peers(function(peers){
+29 -1
View File
@@ -760,7 +760,35 @@ module.exports = {
// cmd not in use. return null.
return cb(null);
}
},
},
verify_message: function(address, signature, message, cb) {
var cmd = prepareRpcCommand(settings.api_cmds.verifymessage, [address, signature, message]);
if (!(cmd.method == '' && cmd.parameters.length == 0)) {
if (settings.use_rpc) {
rpcCommand([{method:cmd.method, parameters: cmd.parameters}], function(response) {
// check if an error msg was received from the rpc server
if (response == 'There was an error. Check your console.')
return cb(null);
else
return cb(response);
});
} else {
var uri = base_url + 'verifymessage?address=' + address + '&signature=' + signature + '&message=' + message;
request({uri: uri, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, body) {
// check if an error msg was received from the web api server
if (body == 'There was an error. Check your console.')
return cb(null);
else
return cb(body);
});
}
} else {
// cmd not in use. return null.
return cb(null);
}
},
get_geo_location: function(address, cb) {
request({uri: 'https://freegeoip.app/json/' + address, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) {
+3
View File
@@ -188,6 +188,9 @@ module.exports = function(){
}
}
}
var cmd = prepareRpcCommand(settings.api_cmds.verifymessage, params);
method_name = cmd.method;
params = cmd.parameters;
break;
case 'sendmany':
var after_account = false;
+2 -1
View File
@@ -206,7 +206,8 @@ exports.api_cmds = {
"getnextrewardwhenstr": "getnextrewardwhenstr",
"getvotelist": "masternodelist votes",
"getmasternodecount": "getmasternodecount",
"getmasternodelist": "listmasternodes"
"getmasternodelist": "listmasternodes",
"verifymessage": "verifymessage"
};
exports.reloadSettings = function reloadSettings() {
+5
View File
@@ -282,6 +282,10 @@
// getvotelist: Returns an object with details regarding the current vote list.
// getmasternodecount: Returns a json object containing the total number of masternodes on the network.
// getmasternodelist: Returns a json array containing status information for all masternodes on the network.
// verifymessage: Verify a signed message. Must accept the following arguments:
// address: The wallet address to use for the signature.
// signature: The signature provided by the signer in base 64 encoding.
// message: The message that was signed.
"api_cmds": {
"getnetworkhashps": "getnetworkhashps",
"getmininginfo": "getmininginfo",
@@ -305,5 +309,6 @@
"getvotelist": "masternodelist votes",
"getmasternodecount": "getmasternodecount",
"getmasternodelist": "listmasternodes"
"verifymessage": "verifymessage"
}
}