Claim address updates
-Claimed addresses now replace actual wallet addresses across all pages of the site -Add new claim_address setting to enable/disable claiming of addresses -Add ability to un-claim an address by signing a blank message
This commit is contained in:
+108
-14
@@ -250,13 +250,50 @@ module.exports = {
|
||||
return fs.existsSync('./tmp/show_sync_message.tmp');
|
||||
},
|
||||
|
||||
update_label: function(hash, message, cb){
|
||||
find_address(hash, false, function(address){
|
||||
if (address){
|
||||
Address.updateOne({a_id:hash}, {
|
||||
name: message,
|
||||
}, function(){
|
||||
return cb();
|
||||
update_label: function(hash, message, cb) {
|
||||
find_address(hash, false, function(address) {
|
||||
if (address) {
|
||||
Address.updateOne({a_id: hash}, {
|
||||
name: message
|
||||
}, function() {
|
||||
// ensure that if this address exists in the richlist that it displays the new alias
|
||||
module.exports.get_richlist(settings.coin, function(richlist) {
|
||||
var updated = false;
|
||||
// loop through received addresses
|
||||
for (r = 0; r < richlist.received.length; r++) {
|
||||
// check if this is the correct address
|
||||
if (richlist.received[r].a_id == hash) {
|
||||
// update the claim name
|
||||
richlist.received[r]['name'] = message;
|
||||
// mark as updated
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
// loop through balance addresses
|
||||
for (b = 0; b < richlist.balance.length; b++) {
|
||||
// check if this is the correct address
|
||||
if (richlist.balance[b].a_id == hash) {
|
||||
// update the claim name
|
||||
richlist.balance[b]['name'] = message;
|
||||
// mark as updated
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
// check if the address was updated in the richlist
|
||||
if (updated) {
|
||||
// save the richlist back to collection
|
||||
Richlist.updateOne({coin: settings.coin}, {
|
||||
received: richlist.received,
|
||||
balance: richlist.balance
|
||||
}, function() {
|
||||
// finished updating the claim label
|
||||
return cb();
|
||||
});
|
||||
} else {
|
||||
// finished updating the claim label
|
||||
return cb();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -320,7 +357,8 @@ module.exports = {
|
||||
return cb(richlist);
|
||||
});
|
||||
},
|
||||
//property: 'received' or 'balance'
|
||||
|
||||
// 'list' variable can be either 'received' or 'balance'
|
||||
update_richlist: function(list, cb){
|
||||
// Create the burn address array so that we omit burned coins from the rich list
|
||||
var oBurnAddresses = [];
|
||||
@@ -330,18 +368,20 @@ module.exports = {
|
||||
// always omit the private address from the richlist
|
||||
oBurnAddresses.push("private_tx");
|
||||
|
||||
if(list == 'received') {
|
||||
Address.find({a_id: { $nin: oBurnAddresses }}, 'a_id balance received').sort({received: 'desc'}).limit(100).exec(function(err, addresses){
|
||||
if (list == 'received') {
|
||||
// Update 'received' richlist data
|
||||
Address.find({a_id: { $nin: oBurnAddresses }}, 'a_id name balance received').sort({received: 'desc'}).limit(100).exec(function(err, addresses) {
|
||||
Richlist.updateOne({coin: settings.coin}, {
|
||||
received: addresses,
|
||||
received: addresses
|
||||
}, function() {
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
} else { //balance
|
||||
Address.find({a_id: { $nin: oBurnAddresses }}, 'a_id balance received').sort({balance: 'desc'}).limit(100).exec(function(err, addresses){
|
||||
} else {
|
||||
// Update 'balance' richlist data
|
||||
Address.find({a_id: { $nin: oBurnAddresses }}, 'a_id name balance received').sort({balance: 'desc'}).limit(100).exec(function(err, addresses) {
|
||||
Richlist.updateOne({coin: settings.coin}, {
|
||||
balance: addresses,
|
||||
balance: addresses
|
||||
}, function() {
|
||||
return cb();
|
||||
});
|
||||
@@ -950,5 +990,59 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
populate_claim_address_names: function(tx, cb) {
|
||||
var addresses = [];
|
||||
|
||||
// loop through vin addresses
|
||||
tx.vin.forEach(function (vin) {
|
||||
// check if this address already exists
|
||||
if (addresses.indexOf(vin.addresses) == -1) {
|
||||
// add address to array
|
||||
addresses.push(vin.addresses);
|
||||
}
|
||||
});
|
||||
|
||||
// loop through vout addresses
|
||||
tx.vout.forEach(function (vout) {
|
||||
// check if this address already exists
|
||||
if (addresses.indexOf(vout.addresses) == -1) {
|
||||
// add address to array
|
||||
addresses.push(vout.addresses);
|
||||
}
|
||||
});
|
||||
|
||||
// loop through address array
|
||||
lib.syncLoop(addresses.length, function (loop) {
|
||||
var a = loop.iteration();
|
||||
|
||||
module.exports.get_address(addresses[a], false, function(address) {
|
||||
if (address && address.name != null && address.name != '') {
|
||||
// look for address in vin
|
||||
for (v = 0; v < tx.vin.length; v++) {
|
||||
// check if this is the correct address
|
||||
if (tx.vin[v].addresses == address.a_id) {
|
||||
// add claim name to array
|
||||
tx.vin[v]['claim_name'] = address.name;
|
||||
}
|
||||
}
|
||||
|
||||
// look for address in vout
|
||||
for (v = 0; v < tx.vout.length; v++) {
|
||||
// check if this is the correct address
|
||||
if (tx.vout[v].addresses == address.a_id) {
|
||||
// add claim name to array
|
||||
tx.vout[v]['claim_name'] = address.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loop.next();
|
||||
});
|
||||
}, function() {
|
||||
// return modified tx object
|
||||
return cb(tx);
|
||||
});
|
||||
},
|
||||
|
||||
fs: fs
|
||||
};
|
||||
Reference in New Issue
Block a user