mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 09:12:05 -07:00
fix(insight): fixed address format for latest version of insight v3
This commit is contained in:
@@ -48,7 +48,7 @@ async function balanceFromBitcore(thisAddress) {
|
||||
|
||||
const path = `${process.env.BITCORE_URL}api/BCH/${network}/address/${addr}/balance`
|
||||
|
||||
console.log(`path: ${path}`)
|
||||
//console.log(`path: ${path}`)
|
||||
|
||||
// Query the Bitcore Node API.
|
||||
const axiosResponse = await axios.get(path)
|
||||
|
||||
@@ -45,16 +45,8 @@ 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 = bchjs.Address.toCashAddress(thisAddress)
|
||||
else addr = bchjs.Address.toLegacyAddress(thisAddress)
|
||||
*/
|
||||
const addr = bchjs.Address.toLegacyAddress(thisAddress)
|
||||
//const addr = bchjs.Address.toLegacyAddress(thisAddress)
|
||||
const addr = bchjs.Address.toCashAddress(thisAddress)
|
||||
|
||||
let path = `${process.env.BITCOINCOM_BASEURL}addr/${addr}`
|
||||
|
||||
@@ -64,7 +56,7 @@ async function detailsFromInsight(thisAddress, currentPage = 0) {
|
||||
const to = from + PAGE_SIZE
|
||||
path = `${path}?from=${from}&to=${to}`
|
||||
|
||||
//console.log(`path: ${path}`)
|
||||
console.log(`insight path: ${path}`)
|
||||
|
||||
// Query the Insight server.
|
||||
const axiosResponse = await axios.get(path)
|
||||
@@ -238,12 +230,7 @@ async function detailsSingle(req, res, next) {
|
||||
// Retrieve UTXO data from the Insight API
|
||||
async function utxoFromInsight(thisAddress) {
|
||||
try {
|
||||
let addr
|
||||
if (
|
||||
process.env.BITCOINCOM_BASEURL === "https://bch-insight.bitpay.com/api/"
|
||||
)
|
||||
addr = bchjs.Address.toCashAddress(thisAddress)
|
||||
else addr = bchjs.Address.toLegacyAddress(thisAddress)
|
||||
const addr = bchjs.Address.toCashAddress(thisAddress)
|
||||
|
||||
const path = `${process.env.BITCOINCOM_BASEURL}addr/${addr}/utxo`
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ const router = express.Router()
|
||||
const util = require("util")
|
||||
util.inspect.defaultOptions = { depth: 1 }
|
||||
|
||||
const BCHJS = require("@chris.troutner/bch-js")
|
||||
const bchjs = new BCHJS()
|
||||
//const BCHJS = require("@chris.troutner/bch-js")
|
||||
//const bchjs = new BCHJS()
|
||||
|
||||
//const BITCORE_URL = process.env.BITCORE_URL
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ function validateNetwork(addr) {
|
||||
|
||||
// Dynamically set these based on env vars. Allows unit testing.
|
||||
function setEnvVars() {
|
||||
const BITBOXHTTP = axios.create({
|
||||
const BitboxHTTP = axios.create({
|
||||
baseURL: process.env.RPC_BASEURL
|
||||
})
|
||||
const username = process.env.RPC_USERNAME
|
||||
|
||||
Reference in New Issue
Block a user