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
|
.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/**
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user