Skip to content
Permalink
Browse files

Address Labels -> Claim Address

  • Loading branch information
TheHolyRoger committed Dec 23, 2019
1 parent 0ea7830 commit ea6038be4950783bd11b4821014f9c33580b6c7c
Showing with 185 additions and 22 deletions.
  1. +3 −0 CHANGELOG
  2. +1 −1 README.md
  3. +3 −0 UPGRADE
  4. +23 −2 app.js
  5. +12 −0 lib/database.js
  6. +3 −2 models/address.js
  7. +1 −1 package.json
  8. +14 −0 routes/index.js
  9. +19 −12 views/address.pug
  10. +98 −0 views/claim_address.pug
  11. +8 −4 views/includes/rl_labels.pug
@@ -1,3 +1,6 @@
1.7.1
* Added "claim address" system - allows users to label addresses by signing messages

1.7.0
* Various updated dependencies & node version
* Switched from Jade to Pug
@@ -1,4 +1,4 @@
Iquidus Explorer - 1.7.0
Iquidus Explorer - 1.7.1
================

An open source block explorer written in node.js.
@@ -1,5 +1,8 @@
Note: All updates require the explorer to be restarted

1.7.0 -> 1.7.1
* nothing required

1.6.2 -> 1.7.0
* Update node (v12 is advised)
* Update mongodb (4.2.x is advised)
25 app.js
@@ -18,7 +18,7 @@ var app = express();
bitcoinapi.setWalletDetails(settings.wallet);
if (settings.heavy != true) {
bitcoinapi.setAccess('only', ['getinfo', 'getnetworkhashps', 'getmininginfo','getdifficulty', 'getconnectioncount',
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction', 'getpeerinfo', 'gettxoutsetinfo']);
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction', 'getpeerinfo', 'gettxoutsetinfo', 'verifymessage']);
} else {
// enable additional heavy api calls
/*
@@ -35,7 +35,7 @@ if (settings.heavy != true) {
bitcoinapi.setAccess('only', ['getinfo', 'getstakinginfo', 'getnetworkhashps', 'getdifficulty', 'getconnectioncount',
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction','getmaxmoney', 'getvote',
'getmaxvote', 'getphase', 'getreward', 'getnextrewardestimate', 'getnextrewardwhenstr',
'getnextrewardwhensec', 'getsupply', 'gettxoutsetinfo']);
'getnextrewardwhensec', 'getsupply', 'gettxoutsetinfo', 'verifymessage']);
}
// view engine setup
app.set('views', path.join(__dirname, 'views'));
@@ -212,6 +212,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});
@@ -342,6 +342,18 @@ module.exports = {
});
},

update_label: function(hash, message, cb){
find_address(hash, function(address){
if(address){
Address.updateOne({a_id:hash}, {
name: message,
}, function(){
return cb();
})
}
})
},

check_stats: function(coin, cb) {
Stats.findOne({coin: coin}, function(err, stats) {
if(stats) {
@@ -3,9 +3,10 @@ var mongoose = require('mongoose')

var AddressSchema = new Schema({
a_id: { type: String, unique: true, index: true},
received: { type: Number, default: 0 },
name: { type: String, default: ''},
received: { type: Number, default: 0, index: true },
sent: { type: Number, default: 0 },
balance: {type: Number, default: 0},
balance: {type: Number, default: 0, index: true},
}, {id: false});

module.exports = mongoose.model('Address', AddressSchema);
@@ -1,6 +1,6 @@
{
"name": "explorer",
"version": "1.7.0",
"version": "1.7.1",
"private": true,
"scripts": {
"start": "node --stack-size=10000 ./bin/cluster",
@@ -109,6 +109,16 @@ function route_get_address(res, hash, count) {
});
}

function route_get_claim_form(res, hash){
db.get_address(hash, function(address) {
if (address) {
res.render("claim_address", { active: "address", address: address});
} else {
route_get_index(res, hash + ' not found');
}
});
}

/* GET home page. */
router.get('/', function(req, res) {
route_get_index(res, null);
@@ -211,6 +221,10 @@ router.get('/block/:hash', function(req, res) {
route_get_block(res, req.params.hash);
});

router.get('/address/:hash/claim', function(req,res){
route_get_claim_form(res, req.params.hash);
});

router.get('/address/:hash', function(req, res) {
route_get_address(res, req.params.hash, settings.txcount);
});
@@ -11,19 +11,26 @@ block content
.panel.panel-default.panel-address-summary
.panel-heading(style='position:relative;')
strong #{address.a_id}
if settings.labels[address.a_id]
if settings.labels[address.a_id].type
label(class='label label-'+settings.labels[address.a_id].type+' pull-right hidden-xs', style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href=settings.labels[address.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
if settings.labels[address.a_id]
if settings.labels[address.a_id].type
label(class='label label-'+settings.labels[address.a_id].type+' pull-right hidden-xs', style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href=settings.labels[address.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
else
label.label.label-default.pull-right.hidden-xs(style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href=settings.labels[address.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
else
label.label.label-default.pull-right.hidden-xs(style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href=settings.labels[address.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
if address.name !== "" && typeof address.name !== "undefined"
label(class='label label-default pull-right hidden-xs', style='margin-left:15px;')
=address.name
else
a.badge.badge-pill.pull-right(href="/address/"+ address.a_id +"/claim" style="font-size: smaller;")
=" Is this yours? Claim it now for free!"
table.table.table-bordered.table-striped.summary-table
thead
tr
@@ -0,0 +1,98 @@
extends layout

block content
script.
$(function () {

$('form').on('submit', function (e) {

e.preventDefault();
var address;
var message;
var signature;
address = $('input#address').val();
message = $('input#message').val();
signature = $('input#signature').val();
var url = '/address/'+address+'/claim';
$.ajax({
type: 'post',
url: url,
data: {
'address': address,
'message': message,
'signature': signature
},
success: function (data) {
if(data.status == "success")
window.location = "/address/"+address;

}
});

});

});
- var balance = ((address.received - address.sent) / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- var balanceParts = balance.split('.');
- var sent = (address.sent /100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- var sentParts = sent.split('.');
- var received = (address.received / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- var receivedParts = received.split('.');
.col-xs-12.col-md-10.col-md-offset-1
.panel.panel-default.panel-address-summary
.panel-heading(style='position:relative;')
strong=address.a_id
if settings.labels[address.a_id]
if settings.labels[address.a_id].type
label(class='badge label-#{ settings.labels[address.a_id].type} pull-right d-none d-sm-block', style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href="#{ settings.labels[address.a_id].url}'", target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
else
label.badge.badge-pill.pull-right.d-none.d-sm-block(style='margin-left:15px;')
=settings.labels[address.a_id].label
if settings.labels[address.a_id].url
a(href='#{settings.labels[address.a_id].url}', target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
table.table.table-bordered.table-striped.summary-table
thead
tr
if settings.show_sent_received == true
th.hidden-xs #{settings.locale.total_sent} (#{settings.symbol})
if address.a_id !== 'coinbase'
if settings.show_sent_received == true
th.hidden-xs #{settings.locale.total_received} (#{settings.symbol})
th #{settings.locale.rl_balance} (#{settings.symbol})
th #{settings.locale.a_qr}
tbody
tr
if settings.show_sent_received == true
td.addr-summary.hidden-xs #{sentParts[0]}.
span.decimal #{sentParts[1]}
if address.a_id !== 'coinbase'
if settings.show_sent_received == true
td.addr-summary.hidden-xs #{receivedParts[0]}.
span.decimal #{receivedParts[1]}
td.addr-summary #{balanceParts[0]}.
span.decimal #{balanceParts[1]}
td.addr-summary
img.qrcode(src='/qr/'+address.a_id)
.panel.panel-default
.panel-heading
strong Claim this Address
form#claimForm
.form-group
fieldset
label.control-label(for='address') Wallet Address
input#address.form-control(type='text' value=address.a_id readonly="")
.form-group
fieldset
label(for='message') Username
input#message.form-control(type='text' placeholder='User Name')
.form-group
fieldset
label(for='signature') Signature
input#signature.form-control(type='text' placeholder='Signature')
button.btn.btn-primary(type='submit') Submit
.footer-padding
@@ -1,13 +1,17 @@
if settings.labels[item.a_id]
if settings.labels[item.a_id].type
label(class='label label-'+settings.labels[item.a_id].type+' hidden-xs', style='margin-left:15px;')
if settings.labels[item.a_id].type
label(class='label label-'+settings.labels[item.a_id].type+' pull-right hidden-xs', style='margin-left:15px;')
=settings.labels[item.a_id].label
if settings.labels[item.a_id].url
a(href=settings.labels[item.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
else
label.label.label-default.hidden-xs(style='margin-left:15px;')
label.label.label-default.pull-right.hidden-xs(style='margin-left:15px;')
=settings.labels[item.a_id].label
if settings.labels[item.a_id].url
a(href=settings.labels[item.a_id].url, target='_blank')
span.fa.fa-question-circle(style='margin-left:5px;')
span.fa.fa-question-circle(style='margin-left:5px;')
else
if item.name !== "" && typeof item.name !== "undefined"
label(class='label label-default pull-right hidden-xs', style='margin-left:15px;')
=item.name

0 comments on commit ea6038b

Please sign in to comment.
You can’t perform that action at this time.