Fix: Address query not working
This commit is contained in:
parent
78fd191839
commit
829be091e2
47
index.html
47
index.html
@ -1134,7 +1134,7 @@
|
|||||||
getRef('transactions_list').innerHTML = '<sm-spinner class="justify-self-center margin-top-1-5"></sm-spinner>';
|
getRef('transactions_list').innerHTML = '<sm-spinner class="justify-self-center margin-top-1-5"></sm-spinner>';
|
||||||
getRef('address_balance').innerHTML = '<sm-spinner class="justify-self-center margin-top-1-5"></sm-spinner>';
|
getRef('address_balance').innerHTML = '<sm-spinner class="justify-self-center margin-top-1-5"></sm-spinner>';
|
||||||
await getExchangeRate();
|
await getExchangeRate();
|
||||||
getAddressDetails(address).then(result => {
|
btcOperator.getAddressData(address).then(result => {
|
||||||
getRef('address_balance').value = formatAmount(getConvertedAmount(result.balance));
|
getRef('address_balance').value = formatAmount(getConvertedAmount(result.balance));
|
||||||
getRef('address_balance').dataset.btcAmount = result.balance;
|
getRef('address_balance').dataset.btcAmount = result.balance;
|
||||||
getRef('address_balance').parentElement.classList.remove('hidden')
|
getRef('address_balance').parentElement.classList.remove('hidden')
|
||||||
@ -1635,51 +1635,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getAddressDetails(address) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
btcOperator.getAddressData(address).then(data => {
|
|
||||||
console.debug(data);
|
|
||||||
let details = {};
|
|
||||||
details.balance = data.balance;
|
|
||||||
details.address = data.address;
|
|
||||||
details.txs = data.txs.map(tx => {
|
|
||||||
let d = {
|
|
||||||
txid: tx.txid,
|
|
||||||
time: tx.time,
|
|
||||||
block: tx.block_no
|
|
||||||
}
|
|
||||||
if (tx.outgoing) {
|
|
||||||
d.type = "out";
|
|
||||||
d.amount = 0;
|
|
||||||
d.receiver = new Set();
|
|
||||||
let change = 0;
|
|
||||||
tx.outgoing.outputs.forEach(o => {
|
|
||||||
if (o.address !== address) {
|
|
||||||
d.receiver.add(o.address)
|
|
||||||
d.amount += parseFloat(o.value)
|
|
||||||
} else
|
|
||||||
change += parseFloat(o.value)
|
|
||||||
});
|
|
||||||
d.receiver = Array.from(d.receiver);
|
|
||||||
d.amount = parseFloat(d.amount.toFixed(8))
|
|
||||||
d.fee = parseFloat((tx.outgoing.value - (d.amount + change)).toFixed(8))
|
|
||||||
if (!d.amount && change > 0) {
|
|
||||||
d.type = "self";
|
|
||||||
d.amount = change
|
|
||||||
delete d.receiver;
|
|
||||||
d.address = address;
|
|
||||||
}
|
|
||||||
} else if (tx.incoming) {
|
|
||||||
d.type = "in";
|
|
||||||
d.amount = parseFloat(tx.incoming.value);
|
|
||||||
d.sender = Array.from(new Set(tx.incoming.inputs.map(i => i.address)));
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
})
|
|
||||||
resolve(details);
|
|
||||||
}).catch(error => reject(error))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user