Add support for vin/vout hashes inside an array

-Some blockchains store certain vin or vout addresses within an array instead of as a simple string which would cause them to be read improperly by the explorer and result in transactions that were not attributed to the proper address. It also caused multiple inputs/outputs from the same address in a single transaction to not be grouped together like other transactions in the explorer
This commit is contained in:
Joe Uhren
2022-07-17 14:28:58 -06:00
parent 58bd8ffec8
commit bfbc50beda
2 changed files with 31 additions and 0 deletions
+12
View File
@@ -122,6 +122,12 @@ function save_tx(txid, blockheight, cb) {
lib.syncLoop(vin.length, function (loop) {
var i = loop.iteration();
// check if address is inside an array
if (Array.isArray(nvin[i].addresses)) {
// extract the address
nvin[i].addresses = nvin[i].addresses[0];
}
update_address(nvin[i].addresses, blockheight, txid, nvin[i].amount, 'vin', function() {
loop.next();
});
@@ -129,6 +135,12 @@ function save_tx(txid, blockheight, cb) {
lib.syncLoop(vout.length, function (subloop) {
var t = subloop.iteration();
// check if address is inside an array
if (Array.isArray(vout[t].addresses)) {
// extract the address
vout[t].addresses = vout[t].addresses[0];
}
if (vout[t].addresses) {
update_address(vout[t].addresses, blockheight, txid, vout[t].amount, 'vout', function() {
subloop.next();