forked from christroutner/koa-api-boilerplate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bch-js): replaced slp-sdk with bch-js
- Loading branch information
1 parent
b7535ad
commit f75d9c3
Showing
6 changed files
with
94 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Configuration settings for bch-js and bch-api. | ||
*/ | ||
|
||
'use strict' | ||
|
||
// default rest API. | ||
let RESTAPI = 'bchjs' | ||
|
||
// Override the RESTAPI setting if envronment variable is set. | ||
if (process.env.RESTAPI && process.env.RESTAPI !== '') { RESTAPI = process.env.RESTAPI } | ||
|
||
// Ensure bch-js can pick up the env var. | ||
process.env.RESTAPI = RESTAPI | ||
|
||
const BCHJS = require('@chris.troutner/bch-js') | ||
const BITBOX = require('slp-sdk') | ||
|
||
const config = {} | ||
|
||
if (RESTAPI === 'bchjs') { | ||
config.BCHLIB = BCHJS.BitboxShim() | ||
config.MAINNET_REST = `https://mainnet.bchjs.cash/v3/` | ||
config.TESTNET_REST = `https://testnet.bchjs.cash/v3/` | ||
config.RESTAPI = 'bchjs' | ||
} | ||
|
||
// Use BITBOX and the bitcoin.com infrastructure. | ||
if (RESTAPI === 'bitcoin.com') { | ||
config.BCHLIB = BITBOX | ||
config.MAINNET_REST = `https://rest.bitcoin.com/v2/` | ||
config.TESTNET_REST = `https://trest.bitcoin.com/v2/` | ||
config.RESTAPI = 'bitcoin.com' | ||
} | ||
|
||
// Use bch-js but use it with the bitcoin.com infrastructure. | ||
if (RESTAPI === 'rest.bitcoin.com') { | ||
config.BCHLIB = BCHJS.BitboxShim() | ||
config.MAINNET_REST = `https://rest.bitcoin.com/v2/` | ||
config.TESTNET_REST = `http://157.245.141.224:3000/v2/` | ||
config.RESTAPI = 'rest.bitcoin.com' | ||
} | ||
|
||
// Use bch-js with local infrastructure. | ||
if (RESTAPI === 'local') { | ||
config.BCHLIB = BCHJS.BitboxShim() | ||
// config.MAINNET_REST = `http://192.168.0.36:12400/v3/` | ||
// config.TESTNET_REST = `http://192.168.0.38:13400/v3/` | ||
config.MAINNET_REST = `http://127.0.0.1:3000/v3/` | ||
config.TESTNET_REST = `http://decatur.hopto.org:13400/v3/` | ||
config.RESTAPI = 'local' | ||
} | ||
|
||
// Use bch-js with decatur infrastructure. | ||
if (RESTAPI === 'decatur') { | ||
config.BCHLIB = BCHJS.BitboxShim() | ||
config.MAINNET_REST = `http://decatur.hopto.org:12400/v3/` | ||
config.TESTNET_REST = `http://decatur.hopto.org:13400/v3/` | ||
config.RESTAPI = 'decatur' | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const common = require('./env/common') | ||
const bchjs = require('./bchjs') | ||
|
||
const env = process.env.APP_ENV || 'development' | ||
console.log(`Starting ${env} environment`) | ||
const config = require(`./env/${env}`) | ||
config.env = env | ||
|
||
module.exports = Object.assign({}, common, config) | ||
module.exports = Object.assign({}, bchjs, common, config) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters