Address Labels -> Claim Address

This commit is contained in:
joeuhren
2020-11-22 14:39:10 -07:00
parent a22ea7c484
commit a66f9cb7e4
9 changed files with 202 additions and 28 deletions
+23 -2
View File
@@ -19,7 +19,7 @@ nodeapi.setWalletDetails(settings.wallet);
if (settings.heavy != true) {
nodeapi.setAccess('only', ['getinfo', 'getnetworkhashps', 'getmininginfo','getdifficulty', 'getconnectioncount',
'getmasternodecount', 'getmasternodelist', 'getvotelist', 'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction',
'getpeerinfo', 'gettxoutsetinfo']);
'getpeerinfo', 'gettxoutsetinfo', 'verifymessage']);
} else {
// enable additional heavy api calls
/*
@@ -36,7 +36,7 @@ if (settings.heavy != true) {
nodeapi.setAccess('only', ['getinfo', 'getstakinginfo', 'getnetworkhashps', 'getdifficulty', 'getconnectioncount',
'getmasternodecount', 'getmasternodelist', 'getvotelist', 'getblockcount', 'getblockhash',
'getblock', 'getrawtransaction', 'getmaxmoney', 'getvote', 'getmaxvote', 'getphase', 'getreward', 'getpeerinfo',
'getnextrewardestimate', 'getnextrewardwhenstr', 'getnextrewardwhensec', 'getsupply', 'gettxoutsetinfo']);
'getnextrewardestimate', 'getnextrewardwhenstr', 'getnextrewardwhensec', 'getsupply', 'gettxoutsetinfo', 'verifymessage']);
}
// determine if cors should be enabled
if (settings.usecors == true) {
@@ -244,6 +244,27 @@ app.use('/ext/getaddresstxsajax/:address', 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){
//console.log('error', error);
//console.log('response', response);
if(body == "false"){
console.log('failed');
res.json({"status": "failed", "error":true, "message": error});
}else if(body == "true"){
db.update_label(address, message, function(){
res.json({"status": "success"});
})
}
});
})
app.use('/ext/connections', function(req,res){
db.get_peers(function(peers){
res.send({data: peers});