More claim address feature updates
-Lots of changes to the claim address page: now supports the ability to enter a wallet address instead of always being read-only; no longer displays address information summary; updated alert text and display with better icons; initial info alert denotes current claim status when viewing an existing address; you can now show/hide claim instructions which are defaulted to hidden; Submit button changed to Claim button; Updated page text and verbiage
-Added new setting, "claim_address_header_menu" which shows/hides a new "Claim Address" header menu item
-Claim url changed from /address/{hash}/claim to /claim and /claim/{hash}
-Added additional error handling for successfully verifying a wallet address that is now known to the explorer
-Added a new locale string for the "Claim Address" header menu
This commit is contained in:
@@ -279,7 +279,7 @@ app.use('/ext/getaddresstxs/:address/:start/:length', function(req,res) {
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/address/:hash/claim', function(req, res) {
|
||||
app.post('/claim', function(req, res) {
|
||||
// initialize the bad-words filter
|
||||
var bad_word_lib = require('bad-words');
|
||||
var bad_word_filter = new bad_word_lib();
|
||||
@@ -294,11 +294,17 @@ app.post('/address/:hash/claim', function(req, res) {
|
||||
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'});
|
||||
db.update_label(req.body.address, req.body.message, function(val) {
|
||||
// check if the update was successful
|
||||
if (val == '')
|
||||
res.json({'status': 'success'});
|
||||
else if (val == 'no_address')
|
||||
res.json({'status': 'failed', 'error': true, 'message': 'Wallet address ' + req.body.address + ' is not valid or does not have any transactions'});
|
||||
else
|
||||
res.json({'status': 'failed', 'error': true, 'message': 'Wallet address or signature is invalid'});
|
||||
});
|
||||
} else
|
||||
res.json({'status': 'failed', 'error': true, 'message': 'There was an error. Check your console'});
|
||||
res.json({'status': 'failed', 'error': true, 'message': 'Wallet address or signature is invalid'});
|
||||
});
|
||||
} else {
|
||||
// message was filtered which would change the signature
|
||||
|
||||
+5
-2
@@ -287,14 +287,17 @@ module.exports = {
|
||||
balance: richlist.balance
|
||||
}, function() {
|
||||
// finished updating the claim label
|
||||
return cb();
|
||||
return cb('');
|
||||
});
|
||||
} else {
|
||||
// finished updating the claim label
|
||||
return cb();
|
||||
return cb('');
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// address is not valid or does not have any transactions
|
||||
return cb('no_address');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ exports.menu_richlist = "Rich List",
|
||||
exports.menu_reward = "Reward",
|
||||
exports.menu_movement = "Movement",
|
||||
exports.menu_node = "Nodes",
|
||||
exports.menu_network = "Network"
|
||||
exports.menu_network = "Network",
|
||||
exports.menu_claim_address = "Claim Address",
|
||||
|
||||
exports.ex_title = "Block Explorer",
|
||||
exports.ex_search_title = "Search",
|
||||
|
||||
@@ -91,6 +91,7 @@ exports.display = {
|
||||
"movement": true,
|
||||
"network": true,
|
||||
"claim_address": true,
|
||||
"claim_address_header_menu": true,
|
||||
"page_header_bgcolor": "",
|
||||
"page_footer_bgcolor": "",
|
||||
"table_header_bgcolor": "",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"menu_movement": "Movement",
|
||||
"menu_node": "Nodes",
|
||||
"menu_network": "Network",
|
||||
"menu_claim_address": "Claim Address",
|
||||
|
||||
// explorer view
|
||||
"ex_title": "Block Explorer",
|
||||
|
||||
+17
-9
@@ -166,15 +166,19 @@ function route_get_address(res, hash, count) {
|
||||
function route_get_claim_form(res, hash) {
|
||||
// check if claiming addresses is enabled
|
||||
if (settings.display.claim_address) {
|
||||
db.get_address(hash, false, function(address) {
|
||||
if (address)
|
||||
res.render("claim_address", { active: "address", address: address, showSync: db.check_show_sync_message()});
|
||||
else
|
||||
route_get_index(res, hash + ' not found');
|
||||
});
|
||||
} else {
|
||||
// check if a hash was passed in
|
||||
if (hash == null || hash == '') {
|
||||
// no hash so just load the claim page without an address
|
||||
res.render("claim_address", { active: "claim-address", hash: hash, claim_name: '', showSync: db.check_show_sync_message()});
|
||||
} else {
|
||||
// lookup hash in the address collection
|
||||
db.get_address(hash, false, function(address) {
|
||||
// load the claim page regardless of whether the address exists or not
|
||||
res.render("claim_address", { active: "claim-address", hash: hash, claim_name: (address == null || address.name == null ? '' : address.name), showSync: db.check_show_sync_message()});
|
||||
});
|
||||
}
|
||||
} else
|
||||
route_get_address(res, hash, settings.txcount);
|
||||
}
|
||||
}
|
||||
|
||||
/* GET home page. */
|
||||
@@ -287,7 +291,11 @@ router.get('/block/:hash', function(req, res) {
|
||||
route_get_block(res, req.params.hash);
|
||||
});
|
||||
|
||||
router.get('/address/:hash/claim', function(req,res){
|
||||
router.get('/claim', function(req, res) {
|
||||
route_get_claim_form(res, '');
|
||||
});
|
||||
|
||||
router.get('/claim/:hash', function(req, res) {
|
||||
route_get_claim_form(res, req.params.hash);
|
||||
});
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@
|
||||
"network": true,
|
||||
// Enable/disable the ability for users to claim a wallet address. NOTE: Disabling this feature after addresses have already been claimed will effectively hide the claimed values and restore the original wallet addresses again
|
||||
"claim_address": true,
|
||||
// Show/hide the "Claim Address" header menu item. NOTE: "claim_address" setting must also be enabled or else the header item will automatically be hidden as well
|
||||
"claim_address_header_menu": true,
|
||||
// page_header_bgcolor: change the background color of the page header
|
||||
// page_footer_bgcolor: change the background color of the page footer
|
||||
// valid options: light, dark, primary, secondary, success, info, warning, danger or leave blank ( "" ) for default colors
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ block content
|
||||
strong #{address.name}
|
||||
include ./includes/rl_labels.pug
|
||||
if !settings.labels[address.a_id] && settings.display.claim_address == true
|
||||
a.badge.badge-pill.float-right.d-none.d-sm-block(href="/address/"+ address.a_id +"/claim" style="font-size:smaller;padding-bottom:0;")
|
||||
a.badge.badge-pill.float-right.d-none.d-sm-block(href='/claim/' + address.a_id, style='font-size:smaller;padding-bottom:0;')
|
||||
if address.name == null || address.name == ''
|
||||
=" Is this yours? Claim it now for free!"
|
||||
else
|
||||
|
||||
+50
-75
@@ -3,25 +3,47 @@ extends layout
|
||||
block content
|
||||
script.
|
||||
$(function () {
|
||||
function generateAlertHTML(alertClass, allowDismiss, headerText, msgText) {
|
||||
return '<div class="alert alert-' + alertClass + (allowDismiss ? ' alert-dismissable' : '') + '" role="alert">' +
|
||||
(allowDismiss ? '<button type="button" class="close" data-dismiss="alert">×</button>' : '') +
|
||||
'<div' + (msgText == null || msgText == '' ? '' : ' class="cardSpacer"') + '>' +
|
||||
'<span class="fas ' + (alertClass == 'success' ? 'fa-check-circle' : (alertClass == 'danger' ? 'fa-exclamation-circle' : (alertClass == 'info' ? 'fa-info-circle' : 'fa-exclamation-triangle'))) + '" style="margin-right:5px"></span>' +
|
||||
'<strong>' + headerText + '</strong>' +
|
||||
'</div>' +
|
||||
(msgText == null || msgText == '' ? '' : '<span>' + msgText + '</span>') +
|
||||
'</div>';
|
||||
}
|
||||
function displayAsText(str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
function showClaimAlert(claimClass, warnMsg, removedClaim) {
|
||||
if ($('#claimAlert').length == 0)
|
||||
$('<div id="claimAlert"></div>').insertBefore('#claimForm');
|
||||
$('#claimAlert').html('<div class="alert alert-' + claimClass + '"><div class="font-weight-bold" style="padding-bottom:10px;">' + (claimClass == 'success' ? (removedClaim ? 'Address claim removed successfully' : 'Address claimed successfully') : (claimClass == 'danger' ? 'Failed to claim address' : 'Required field missing')) + '</div> ' + (claimClass == 'success' ? 'This address will now be referred to as <strong>' + (removedClaim ? $('input#address').val() : displayAsText($('#message').val())) + '</strong> throughout the website' : warnMsg) + '.</div>');
|
||||
$('#claimAlert').html(generateAlertHTML(claimClass, true, (claimClass == 'success' ? (removedClaim ? 'Address claim removed successfully' : 'Address claimed successfully') : (claimClass == 'danger' ? 'Failed to claim address' : 'Required field missing')), (claimClass == 'success' ? '<strong>' + $('input#address').val() + '</strong> will now be referred to as <strong>' + (removedClaim ? $('input#address').val() : displayAsText($('#message').val())) + '</strong> throughout the website' : warnMsg) + '.'));
|
||||
fixFooterHeightAndPosition();
|
||||
}
|
||||
|
||||
$('#claimInstructions').on('show.bs.collapse', function () {
|
||||
$('#showClaimInstructions').html('<i class="fas fa-angle-down" style="margin-right:5px;"></i><span>Hide claim instructions</span>');
|
||||
}).on('hide.bs.collapse', function () {
|
||||
$('#showClaimInstructions').html('<i class="fas fa-angle-up" style="margin-right:5px;"></i><span>Show claim instructions</span>');
|
||||
}).on('shown.bs.collapse', function () {
|
||||
fixFooterHeightAndPosition();
|
||||
}).on('hidden.bs.collapse', function () {
|
||||
fixFooterHeightAndPosition();
|
||||
});
|
||||
$('#claimForm').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var address = $('input#address').val();
|
||||
var message = $('input#message').val();
|
||||
var signature = $('input#signature').val();
|
||||
var url = '/address/'+address+'/claim';
|
||||
var url = '/claim';
|
||||
|
||||
if (signature == null || signature.trim().length == 0) {
|
||||
if (address == null || address.trim().length == 0) {
|
||||
showClaimAlert('warning', 'Please enter the wallet address you wish to claim', false);
|
||||
$('input#address').focus();
|
||||
} else if (signature == null || signature.trim().length == 0) {
|
||||
showClaimAlert('warning', 'Please enter the signature value from your wallet software', false);
|
||||
$('input#signature').focus();
|
||||
$('input#signature').focus();
|
||||
} else {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
@@ -37,85 +59,35 @@ block content
|
||||
});
|
||||
}
|
||||
});
|
||||
if ('!{hash}' != 'null' && '!{hash}' != '') {
|
||||
$('<div id="claimAlert"></div>').insertBefore('#claimForm');
|
||||
$('#claimAlert').html(generateAlertHTML('info', true, ('!{claim_name}' == '' ? 'Unc' : 'C') + 'laimed address', '<strong>!{hash}</strong> is currently ' + ('!{claim_name}' == '' ? 'un' : '') + 'claimed' + ('!{claim_name}' == '' ? '' : ' as <strong>' + displayAsText('!{claim_name}') + '.</strong>')));
|
||||
}
|
||||
});
|
||||
- var balance = Number((address.received - address.sent) / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
|
||||
- var balanceParts = balance.split('.');
|
||||
- var sent = Number(address.sent /100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
|
||||
- var sentParts = sent.split('.');
|
||||
- var received = Number(address.received / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
|
||||
- var receivedParts = received.split('.');
|
||||
if address.a_id !== 'coinbase' || settings.show_sent_received == true
|
||||
script.
|
||||
$(document).ready(function() {
|
||||
$('.summary-table').dataTable({
|
||||
info: false,
|
||||
paging: false,
|
||||
searching: false,
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
fnDrawCallback: function(settings) {
|
||||
fixDataTableColumns();
|
||||
}
|
||||
})
|
||||
});
|
||||
.col-xs-12.col-md-12.cardSpacer
|
||||
if address.a_id !== 'coinbase' || settings.show_sent_received == true
|
||||
.card.card-default.border-0.card-address-summary.cardSpacer
|
||||
.card-header(style='position:relative;')
|
||||
if typeof address.name == null || address.name == ''
|
||||
strong #{address.a_id}
|
||||
else
|
||||
strong #{address.name}
|
||||
include ./includes/rl_labels.pug
|
||||
table.table.table-bordered.table-striped.summary-table.mobile-border-right(style='border-top:0;margin-top:0 !important;')
|
||||
- var theadClasses = [];
|
||||
if settings.display.table_header_bgcolor != null && settings.display.table_header_bgcolor != ''
|
||||
- theadClasses.push('thead-' + settings.display.table_header_bgcolor);
|
||||
thead(class=theadClasses)
|
||||
tr
|
||||
if address.a_id !== 'coinbase'
|
||||
th.text-center #{settings.locale.rl_balance}
|
||||
span.small (#{settings.symbol})
|
||||
if settings.show_sent_received == true
|
||||
th.text-center #{settings.locale.total_sent}
|
||||
span.small (#{settings.symbol})
|
||||
if address.a_id !== 'coinbase' && settings.show_sent_received == true
|
||||
th.text-center #{settings.locale.total_received}
|
||||
span.small (#{settings.symbol})
|
||||
if address.a_id !== 'coinbase'
|
||||
th.text-center #{settings.locale.a_qr}
|
||||
tbody
|
||||
tr
|
||||
if address.a_id !== 'coinbase'
|
||||
td.text-center.addr-summary #{balanceParts[0]}.
|
||||
span.decimal #{balanceParts[1]}
|
||||
if settings.show_sent_received == true
|
||||
td.text-center.addr-summary #{sentParts[0]}.
|
||||
span.decimal #{sentParts[1]}
|
||||
if address.a_id !== 'coinbase' && settings.show_sent_received == true
|
||||
td.text-center.addr-summary #{receivedParts[0]}.
|
||||
span.decimal #{receivedParts[1]}
|
||||
if address.a_id !== 'coinbase'
|
||||
td.text-center.addr-summary
|
||||
img.qrcode(src='/qr/' + address.a_id)
|
||||
.col-xs-12.col-md-12
|
||||
.card.card-default.border-0.cardSpacer
|
||||
.card-header
|
||||
strong Claim this Address
|
||||
strong Claim Wallet Address
|
||||
.card-body
|
||||
div.alert.alert-primary
|
||||
a#showClaimInstructions.badge.badge-info(href='#claimInstructions', style='font-size:100%;margin-bottom:15px;', data-toggle='collapse' role='button' aria-expanded='false' aria-controls='claimInstructions')
|
||||
i.fas.fa-angle-up(style='margin-right:5px;')
|
||||
span Show claim instructions
|
||||
div#claimInstructions.alert.alert-primary.collapse
|
||||
div
|
||||
span You can use the
|
||||
span Use the
|
||||
span.font-weight-bold Sign Message
|
||||
span feature from your
|
||||
span.font-weight-bold #{settings.coin}
|
||||
span wallet to verify ownership of this address.
|
||||
span wallet to verify ownership of a wallet address that belongs to you.
|
||||
br
|
||||
div Enter the following data into the wallet software:
|
||||
br
|
||||
div
|
||||
span.font-weight-bold Address:
|
||||
span #{address.a_id}
|
||||
if hash == null || hash == ''
|
||||
span=' <wallet address from the form below>'
|
||||
else
|
||||
span #{hash}
|
||||
div
|
||||
span.font-weight-bold Message:
|
||||
span=' <display name from the form below>'
|
||||
@@ -125,11 +97,11 @@ block content
|
||||
span.font-weight-bold Sign Message
|
||||
span button in the wallet, and copy/paste the resulting
|
||||
span.font-weight-bold Signature
|
||||
span in the form below.
|
||||
span at the bottom of this form.
|
||||
br
|
||||
div
|
||||
span Finally, click the
|
||||
span.font-weight-bold Submit
|
||||
span.font-weight-bold Claim
|
||||
span button below to claim your address, which will display your custom display name instead of the default wallet address on this site.
|
||||
br
|
||||
div
|
||||
@@ -139,7 +111,10 @@ block content
|
||||
.form-group
|
||||
fieldset.entryField
|
||||
label(for='address') Wallet Address
|
||||
input#address.form-control(type='text' value=address.a_id readonly="")
|
||||
if hash == null || hash == ''
|
||||
input#address.form-control(type='text', maxlength='70')
|
||||
else
|
||||
input#address.form-control(type='text', value=hash, readonly='readonly', maxlength='70')
|
||||
.form-group
|
||||
fieldset.entryField
|
||||
label(for='message') Display Name
|
||||
@@ -148,4 +123,4 @@ block content
|
||||
fieldset.entryField
|
||||
label(for='signature') Signature
|
||||
input#signature.form-control(type='text', placeholder='Signature', maxlength='100')
|
||||
button.btn.btn-primary(type='submit') Submit
|
||||
button.btn.btn-success(type='submit') Claim
|
||||
@@ -345,6 +345,11 @@ html(lang='en')
|
||||
a.nav-link(href='/info')
|
||||
span.fa.fa-info-circle
|
||||
span.margin-left-5 #{settings.locale.menu_api}
|
||||
if settings.display.claim_address_header_menu == true && settings.display.claim_address == true
|
||||
li#claim-address
|
||||
a.nav-link.loading(href='/claim')
|
||||
span.far.fa-address-card
|
||||
span.margin-left-5 #{settings.locale.menu_claim_address}
|
||||
div#body-container(style='margin-top:' + (settings.sticky_header == true ? '80px;' : '20px'))
|
||||
if showSync != null && showSync == true
|
||||
.col-lg-12
|
||||
|
||||
Reference in New Issue
Block a user