Merge pull request #23 from christroutner/bch-js-updates

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