mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Updates for bch-js
This commit is contained in:
@@ -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/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user