fix(insight): fixed address format for latest version of insight v3

This commit is contained in:
Chris Troutner
2019-07-08 13:20:29 -07:00
parent 152c2acb09
commit 37c246f92d
4 changed files with 8 additions and 21 deletions
+1 -1
View File
@@ -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)
+4 -17
View File
@@ -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`
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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