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
+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 {