Updates for bch-js

This commit is contained in:
Chris Troutner
2019-07-07 12:58:27 -07:00
parent c58716dc07
commit 0124323350
5 changed files with 16 additions and 3 deletions
+2
View File
@@ -3,6 +3,8 @@ node_modules/
.env .env
start-local-server start-local-server
test-local-server test-local-server
start-decatur-main
start-decatur-test
coverage coverage
start-my-infra start-my-infra
dist/routes/** dist/routes/**
+2
View File
@@ -48,6 +48,8 @@ async function balanceFromBitcore(thisAddress) {
const path = `${process.env.BITCORE_URL}api/BCH/${network}/address/${addr}/balance` const path = `${process.env.BITCORE_URL}api/BCH/${network}/address/${addr}/balance`
console.log(`path: ${path}`)
// Query the Bitcore Node API. // Query the Bitcore Node API.
const axiosResponse = await axios.get(path) const axiosResponse = await axios.get(path)
const retData = axiosResponse.data const retData = axiosResponse.data
+5 -3
View File
@@ -175,6 +175,7 @@ async function balanceBulk(req, res, next) {
// Loops through each address and creates an array of Promises, querying // Loops through each address and creates an array of Promises, querying
// Insight API in parallel. // Insight API in parallel.
addresses = addresses.map(async (address, index) => addresses = addresses.map(async (address, index) =>
//console.log(`address: ${address}`)
balanceFromBlockbook(address) balanceFromBlockbook(address)
) )
@@ -340,9 +341,10 @@ async function utxosBulk(req, res, next) {
// Loops through each address and creates an array of Promises, querying // Loops through each address and creates an array of Promises, querying
// Insight API in parallel. // Insight API in parallel.
addresses = addresses.map(async (address, index) => addresses = addresses.map(async (address, index) => {
utxosFromBlockbook(address) console.log(`address: ${address}`)
) return utxosFromBlockbook(address)
})
// Wait for all parallel Insight requests to return. // Wait for all parallel Insight requests to return.
const result = await axios.all(addresses) const result = await axios.all(addresses)
+6
View File
@@ -45,12 +45,16 @@ function root(req, res, next) {
// Returns a Promise. // Returns a Promise.
async function detailsFromInsight(thisAddress, currentPage = 0) { async function detailsFromInsight(thisAddress, currentPage = 0) {
try { try {
/*
let addr let addr
if ( if (
process.env.BITCOINCOM_BASEURL === "https://bch-insight.bitpay.com/api/" process.env.BITCOINCOM_BASEURL === "https://bch-insight.bitpay.com/api/"
) )
addr = BITBOX.Address.toCashAddress(thisAddress) addr = BITBOX.Address.toCashAddress(thisAddress)
else addr = BITBOX.Address.toLegacyAddress(thisAddress) else addr = BITBOX.Address.toLegacyAddress(thisAddress)
*/
const addr = BITBOX.Address.toLegacyAddress(thisAddress)
let path = `${process.env.BITCOINCOM_BASEURL}addr/${addr}` let path = `${process.env.BITCOINCOM_BASEURL}addr/${addr}`
@@ -60,6 +64,8 @@ async function detailsFromInsight(thisAddress, currentPage = 0) {
const to = from + PAGE_SIZE const to = from + PAGE_SIZE
path = `${path}?from=${from}&to=${to}` path = `${path}?from=${from}&to=${to}`
//console.log(`path: ${path}`)
// Query the Insight server. // Query the Insight server.
const axiosResponse = await axios.get(path) const axiosResponse = await axios.get(path)
const retData = axiosResponse.data const retData = axiosResponse.data
+1
View File
@@ -70,6 +70,7 @@ async function detailsByHashSingle(req, res, next) {
async function detailsByHashBulk(req, res, next) { async function detailsByHashBulk(req, res, next) {
try { try {
const hashes = req.body.hashes const hashes = req.body.hashes
//console.log(`hashes: ${JSON.stringify(hashes, null, 2)}`)
// Reject if hashes is not an array. // Reject if hashes is not an array.
if (!Array.isArray(hashes)) { if (!Array.isArray(hashes)) {