AddressTX: include balance history and show in address history

This commit is contained in:
joeuhren
2020-11-20 16:50:53 -07:00
parent 7008b31424
commit 94f8c97d13
4 changed files with 21 additions and 4 deletions
+1
View File
@@ -213,6 +213,7 @@ app.use('/ext/getaddresstxsajax/:address', function(req,res){
row.push(txs[i].txid);
row.push(out);
row.push(vin);
row.push(txs[i].balance);
data.push(row);
}
}
+13 -1
View File
@@ -90,6 +90,7 @@ function update_address(hash, txid, amount, type, cb) {
if (typeof address_tx == "undefined") {
var newAddressTx = new AddressTx({
a_id: hash,
balance: received - sent,
txid: txid
});
newAddressTx.save(function(err) {
@@ -100,7 +101,13 @@ function update_address(hash, txid, amount, type, cb) {
}
});
} else {
return cb(); //duplicate
AddressTx.updateOne({a_id: hash, txid: txid}, {
a_id: hash,
balance: received - sent,
txid: txid
}, function() {
return cb();
});
}
});
});
@@ -127,6 +134,7 @@ function update_address(hash, txid, amount, type, cb) {
} else {
var newAddressTx = new AddressTx({
a_id: hash,
balance: amount,
txid: txid
});
newAddressTx.save(function(err) {
@@ -514,9 +522,13 @@ module.exports = {
var i = loop.iteration();
find_tx(hashes[i].txid, function (tx) {
if (tx && !txs.includes(tx)) {
// tx = {...hashes[i], ...tx}
tx.balance = hashes[i].balance;
txs.push(tx);
loop.next();
} else if (!txs.includes(tx)) {
// tx = {...hashes[i], ...tx}
tx.balance = hashes[i].balance;
txs.push("1. Not found");
loop.next();
} else {
+2 -1
View File
@@ -3,7 +3,8 @@ var mongoose = require('mongoose')
var AddressTXSchema = new Schema({
a_id: { type: String, index: true},
txid: { type: String, lowercase: true, index: true}
txid: { type: String, lowercase: true, index: true},
balance: { type: Number, default: 0}
}, {id: false});
module.exports = mongoose.model('AddressTx', AddressTXSchema);
+5 -2
View File
@@ -25,6 +25,7 @@ script.
var txhash = data[1]; //variables for better readability
var out = data[2]; //variables for better readability
var vin = data[3]; //variables for better readability
var balance = (data[4] / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true}); //variables for better readability
$("td:eq(0)", row).html(timestamp);
$("td:eq(1)", row).html('<a href="/tx/' + txhash + '">' + txhash + '</a>');
@@ -43,13 +44,14 @@ script.
amount = amount.toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
$("td:eq(2)", row).html(amount).addClass("info");
}
}else if(out > 0) {
} else if (out > 0) {
amount = (out / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
$("td:eq(2)", row).html("+" + amount).addClass("success");
}else{
} else {
amount = (vin / 100000000).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
$("td:eq(2)", row).html("-" + amount).addClass("danger");
}
$("td:eq(3)", row).html(balance);
},
});
@@ -60,4 +62,5 @@ table#address-txs.table.table-bordered.table-striped
th.hidden-xs #{settings.locale.timestamp}
th.hidden-xs #{settings.locale.tx_hash}
th #{settings.locale.mkt_amount} (#{settings.symbol})
th #{settings.locale.rl_balance} (#{settings.symbol})
tbody