|
|
@@ -35,7 +35,10 @@ util.inspect.defaultOptions = { depth: 5 }
|
|
|
|
|
|
|
|
|
|
|
|
// Determine the Access password for a private instance of SLPDB.
|
|
|
|
// Determine the Access password for a private instance of SLPDB.
|
|
|
|
// https://gist.github.com/christroutner/fc717ca704dec3dded8b52fae387eab2
|
|
|
|
// https://gist.github.com/christroutner/fc717ca704dec3dded8b52fae387eab2
|
|
|
|
const SLPDB_PASS = process.env.SLPDB_PASS ? process.env.SLPDB_PASS : 'BITBOX'
|
|
|
|
// Password for General Purpose (GP) SLPDB.
|
|
|
|
|
|
|
|
const SLPDB_PASS_GP = process.env.SLPDB_PASS_GP ? process.env.SLPDB_PASS_GP : 'BITBOX'
|
|
|
|
|
|
|
|
// Password for Whitelist (WL) SLPDB.
|
|
|
|
|
|
|
|
const SLPDB_PASS_WL = process.env.SLPDB_PASS_WL ? process.env.SLPDB_PASS_WL : 'BITBOX'
|
|
|
|
|
|
|
|
|
|
|
|
// const rawtransactions = require('./full-node/rawtransactions')
|
|
|
|
// const rawtransactions = require('./full-node/rawtransactions')
|
|
|
|
const RawTransactions = require('./full-node/rawtransactions')
|
|
|
|
const RawTransactions = require('./full-node/rawtransactions')
|
|
|
@@ -43,9 +46,9 @@ const rawTransactions = new RawTransactions()
|
|
|
|
|
|
|
|
|
|
|
|
// Setup REST and TREST URLs used by slpjs
|
|
|
|
// Setup REST and TREST URLs used by slpjs
|
|
|
|
// Dev note: this allows for unit tests to mock the URL.
|
|
|
|
// Dev note: this allows for unit tests to mock the URL.
|
|
|
|
if (!process.env.REST_URL) process.env.REST_URL = 'https://rest.bitcoin.com/v2/'
|
|
|
|
if (!process.env.REST_URL) process.env.REST_URL = 'https://bchn.fullstack.cash/v4/'
|
|
|
|
if (!process.env.TREST_URL) {
|
|
|
|
if (!process.env.TREST_URL) {
|
|
|
|
process.env.TREST_URL = 'https://trest.bitcoin.com/v2/'
|
|
|
|
process.env.TREST_URL = 'https://testnet.fullstack.cash/v4/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let _this
|
|
|
|
let _this
|
|
|
@@ -434,7 +437,7 @@ class Slp {
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
// Request options
|
|
|
|
// Request options
|
|
|
|
const opt = {
|
|
|
|
const opt = {
|
|
|
|
method: 'get',
|
|
|
|
method: 'get',
|
|
|
@@ -585,7 +588,7 @@ class Slp {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
|
|
|
|
|
|
|
|
// Collect an array of promises, one for each request to slpserve.
|
|
|
|
// Collect an array of promises, one for each request to slpserve.
|
|
|
|
// This is a nested array of promises.
|
|
|
|
// This is a nested array of promises.
|
|
|
@@ -807,7 +810,7 @@ class Slp {
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
const opt = {
|
|
|
|
const opt = {
|
|
|
|
method: 'get',
|
|
|
|
method: 'get',
|
|
|
|
baseURL: url,
|
|
|
|
baseURL: url,
|
|
|
@@ -996,7 +999,7 @@ class Slp {
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
// console.log('url: ', url)
|
|
|
|
// console.log('url: ', url)
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
|
|
|
|
|
|
|
|
// Get data from SLPDB.
|
|
|
|
// Get data from SLPDB.
|
|
|
|
const opt = {
|
|
|
|
const opt = {
|
|
|
@@ -1130,7 +1133,7 @@ class Slp {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
|
|
|
|
|
|
|
|
const s = JSON.stringify(query)
|
|
|
|
const s = JSON.stringify(query)
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
@@ -1330,7 +1333,7 @@ class Slp {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsWL()
|
|
|
|
|
|
|
|
|
|
|
|
const s = JSON.stringify(query)
|
|
|
|
const s = JSON.stringify(query)
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
@@ -1424,7 +1427,7 @@ class Slp {
|
|
|
|
const url = `${process.env.SLPDB_WHITELIST_URL}q/${b64}`
|
|
|
|
const url = `${process.env.SLPDB_WHITELIST_URL}q/${b64}`
|
|
|
|
// console.log('url: ', url)
|
|
|
|
// console.log('url: ', url)
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsWL()
|
|
|
|
|
|
|
|
|
|
|
|
// Get data from SLPDB.
|
|
|
|
// Get data from SLPDB.
|
|
|
|
const opt = {
|
|
|
|
const opt = {
|
|
|
@@ -1567,7 +1570,7 @@ class Slp {
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const b64 = Buffer.from(s).toString('base64')
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
const url = `${process.env.SLPDB_URL}q/${b64}`
|
|
|
|
|
|
|
|
|
|
|
|
const options = _this.generateCredentials()
|
|
|
|
const options = _this.generateCredentialsGP()
|
|
|
|
const opt = {
|
|
|
|
const opt = {
|
|
|
|
method: 'get',
|
|
|
|
method: 'get',
|
|
|
|
baseURL: url,
|
|
|
|
baseURL: url,
|
|
|
@@ -1727,11 +1730,32 @@ class Slp {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Generates a Basic Authorization header for slpserve.
|
|
|
|
// Generates a Basic Authorization header for slpserve.
|
|
|
|
generateCredentials () {
|
|
|
|
generateCredentialsGP () {
|
|
|
|
// Generate the Basic Authentication header for a private instance of SLPDB.
|
|
|
|
// Generate the Basic Authentication header for a private instance of SLPDB.
|
|
|
|
const username = 'BITBOX'
|
|
|
|
const username = 'BITBOX'
|
|
|
|
const password = SLPDB_PASS
|
|
|
|
const password = SLPDB_PASS_GP
|
|
|
|
const combined = `${username}:${password}`
|
|
|
|
const combined = `${username}:${password}`
|
|
|
|
|
|
|
|
// console.log(`combined: ${combined}`)
|
|
|
|
|
|
|
|
var base64Credential = Buffer.from(combined).toString('base64')
|
|
|
|
|
|
|
|
var readyCredential = `Basic ${base64Credential}`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
authorization: readyCredential
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
timeout: 15000
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return options
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generates a Basic Authorization header for slpserve.
|
|
|
|
|
|
|
|
generateCredentialsWL () {
|
|
|
|
|
|
|
|
// Generate the Basic Authentication header for a private instance of SLPDB.
|
|
|
|
|
|
|
|
const username = 'BITBOX'
|
|
|
|
|
|
|
|
const password = SLPDB_PASS_WL
|
|
|
|
|
|
|
|
const combined = `${username}:${password}`
|
|
|
|
|
|
|
|
console.log(`combined: ${combined}`)
|
|
|
|
var base64Credential = Buffer.from(combined).toString('base64')
|
|
|
|
var base64Credential = Buffer.from(combined).toString('base64')
|
|
|
|
var readyCredential = `Basic ${base64Credential}`
|
|
|
|
var readyCredential = `Basic ${base64Credential}`
|
|
|
|
|
|
|
|
|
|
|
|