mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-22 00:52:01 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b728fb45d | ||
|
|
d4dbce8df0 | ||
|
|
2419aeceaa | ||
|
|
158b009069 | ||
|
|
f3c3250a69 | ||
|
|
5ae4db88c3 | ||
|
|
33e161df26 | ||
|
|
81c910361c | ||
|
|
9751a39538 | ||
|
|
7058f77ee9 | ||
|
|
ad580d67a4 | ||
|
|
acc0300a44 | ||
|
|
4e1b806230 | ||
|
|
357e350176 | ||
|
|
f6140acc76 | ||
|
|
df65b12aab | ||
|
|
754b4cd807 | ||
|
|
3c6079e54c | ||
|
|
18621cd76c | ||
|
|
456159a4cc | ||
|
|
33e723befe | ||
|
|
30fdee1920 | ||
|
|
feb336c331 | ||
|
|
8bacc0a991 | ||
|
|
d22f1ec8a6 |
Generated
+45
-24
@@ -10,7 +10,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@psf/bip21": "^2.0.1",
|
||||
"@psf/bip32-utils": "^0.13.1",
|
||||
"@psf/bip32-utils": "^1.0.0",
|
||||
"@psf/bitcoincash-ops": "^2.0.0",
|
||||
"@psf/bitcoincashjs-lib": "^4.0.2",
|
||||
"@psf/coininfo": "^4.0.0",
|
||||
@@ -576,11 +576,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@psf/bip32-utils": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@psf/bip32-utils/-/bip32-utils-0.13.1.tgz",
|
||||
"integrity": "sha512-5yM2o4TXW3gWKI3zxUFj9eeYqMYbA4Q1w+ptcfb+XnGpSZLrmwGtX48q8rApIKtikRceMEFXp1Jq6ed+bS+1nA==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@psf/bip32-utils/-/bip32-utils-1.0.0.tgz",
|
||||
"integrity": "sha512-cWE+uZsGyS2PsE5+bplNq7w/oE3/wGGP0pZV9TiSNMIQvJguxfu7Ruk2FuzROcaVysBclDaL70A9N3sAnworGA==",
|
||||
"dependencies": {
|
||||
"keccak": "^1.3.0",
|
||||
"keccak": "^3.0.1",
|
||||
"nyc": "*",
|
||||
"standard": "^11.0.1",
|
||||
"tape": "*"
|
||||
@@ -5697,18 +5697,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/keccak": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz",
|
||||
"integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz",
|
||||
"integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"bindings": "^1.2.1",
|
||||
"inherits": "^2.0.3",
|
||||
"nan": "^2.2.1",
|
||||
"safe-buffer": "^5.1.0"
|
||||
"node-addon-api": "^2.0.0",
|
||||
"node-gyp-build": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/kind-of": {
|
||||
@@ -6878,6 +6876,11 @@
|
||||
"@sinonjs/commons": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
|
||||
},
|
||||
"node_modules/node-emoji": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz",
|
||||
@@ -6915,6 +6918,16 @@
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-gyp-build": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz",
|
||||
"integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==",
|
||||
"bin": {
|
||||
"node-gyp-build": "bin.js",
|
||||
"node-gyp-build-optional": "optional.js",
|
||||
"node-gyp-build-test": "build-test.js"
|
||||
}
|
||||
},
|
||||
"node_modules/node-mocks-http": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/node-mocks-http/-/node-mocks-http-1.10.1.tgz",
|
||||
@@ -17611,11 +17624,11 @@
|
||||
}
|
||||
},
|
||||
"@psf/bip32-utils": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@psf/bip32-utils/-/bip32-utils-0.13.1.tgz",
|
||||
"integrity": "sha512-5yM2o4TXW3gWKI3zxUFj9eeYqMYbA4Q1w+ptcfb+XnGpSZLrmwGtX48q8rApIKtikRceMEFXp1Jq6ed+bS+1nA==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@psf/bip32-utils/-/bip32-utils-1.0.0.tgz",
|
||||
"integrity": "sha512-cWE+uZsGyS2PsE5+bplNq7w/oE3/wGGP0pZV9TiSNMIQvJguxfu7Ruk2FuzROcaVysBclDaL70A9N3sAnworGA==",
|
||||
"requires": {
|
||||
"keccak": "^1.3.0",
|
||||
"keccak": "^3.0.1",
|
||||
"nyc": "*",
|
||||
"standard": "^11.0.1",
|
||||
"tape": "*"
|
||||
@@ -21827,14 +21840,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"keccak": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz",
|
||||
"integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz",
|
||||
"integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==",
|
||||
"requires": {
|
||||
"bindings": "^1.2.1",
|
||||
"inherits": "^2.0.3",
|
||||
"nan": "^2.2.1",
|
||||
"safe-buffer": "^5.1.0"
|
||||
"node-addon-api": "^2.0.0",
|
||||
"node-gyp-build": "^4.2.0"
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
@@ -22815,6 +22826,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
|
||||
},
|
||||
"node-emoji": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz",
|
||||
@@ -22848,6 +22864,11 @@
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true
|
||||
},
|
||||
"node-gyp-build": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz",
|
||||
"integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg=="
|
||||
},
|
||||
"node-mocks-http": {
|
||||
"version": "1.10.1",
|
||||
"resolved": "https://registry.npmjs.org/node-mocks-http/-/node-mocks-http-1.10.1.tgz",
|
||||
|
||||
+5
-2
@@ -16,8 +16,11 @@
|
||||
"test:integration:local:abc": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 test/integration && mocha --timeout 30000 test/integration/chains/abc/",
|
||||
"test:integration:local:bchn": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/",
|
||||
"test:integration:local:testnet": "RESTURL=http://localhost:4000/v4/ mocha --timeout 30000 test/integration/chains/testnet",
|
||||
"test:integration:decatur:bchn": "export RESTURL=http://192.168.0.36:3000/v4/ && mocha --timeout 30000 test/integration/",
|
||||
"test:temp": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 -g '#hydrateUtxos' test/integration/",
|
||||
"test:temp2": "mocha --timeout=30000 -g '#Util' test/unit/",
|
||||
"test:temp2": "mocha --timeout=30000 -g '#decodeOpReturn' test/unit/",
|
||||
"test:temp3": "export RESTURL=https://bchn.fullstack.cash/v4/ && mocha --timeout 30000 -g '#hydrateUtxos' test/integration/",
|
||||
"test:temp4": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 -g '#decodeOpReturn' test/integration/",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"coverage:report": "nyc --reporter=html mocha --timeout 25000 test/unit/",
|
||||
"docs": "./node_modules/.bin/apidoc -i src/ -o docs",
|
||||
@@ -31,7 +34,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@psf/bip21": "^2.0.1",
|
||||
"@psf/bip32-utils": "^0.13.1",
|
||||
"@psf/bip32-utils": "^1.0.0",
|
||||
"@psf/bitcoincash-ops": "^2.0.0",
|
||||
"@psf/bitcoincashjs-lib": "^4.0.2",
|
||||
"@psf/coininfo": "^4.0.0",
|
||||
|
||||
+3
-2
@@ -284,7 +284,7 @@ class ElectrumX {
|
||||
* }
|
||||
*
|
||||
*/
|
||||
async transactions (address) {
|
||||
async transactions (address, usrObj = null) {
|
||||
try {
|
||||
// Handle single address.
|
||||
if (typeof address === 'string') {
|
||||
@@ -299,7 +299,8 @@ class ElectrumX {
|
||||
const response = await axios.post(
|
||||
`${this.restURL}electrumx/transactions`,
|
||||
{
|
||||
addresses: address
|
||||
addresses: address,
|
||||
usrObj // pass user data when making an internal call.
|
||||
},
|
||||
_this.axiosOptions
|
||||
)
|
||||
|
||||
@@ -263,7 +263,7 @@ class RawTransactions {
|
||||
* // time: 1547752564,
|
||||
* // blocktime: 1547752564 } ]
|
||||
*/
|
||||
async getRawTransaction (txid, verbose = false) {
|
||||
async getRawTransaction (txid, verbose = false, usrObj = null) {
|
||||
try {
|
||||
if (typeof txid === 'string') {
|
||||
const response = await axios.get(
|
||||
@@ -278,7 +278,8 @@ class RawTransactions {
|
||||
url: `${this.restURL}rawtransactions/getRawTransaction`,
|
||||
data: {
|
||||
txids: txid,
|
||||
verbose: verbose
|
||||
verbose: verbose,
|
||||
usrObj // pass user data when making an internal call.
|
||||
},
|
||||
headers: _this.axiosOptions.headers
|
||||
}
|
||||
|
||||
+58
-27
@@ -436,11 +436,11 @@ class Utils {
|
||||
// will be like the examples above. If SLPDB has fallen behind real-time
|
||||
// processing, it will return this output:
|
||||
// [ null ]
|
||||
async validateTxid (txid, origin = null) {
|
||||
async validateTxid (txid, usrObj = null) {
|
||||
const path = `${this.restURL}slp/validateTxid`
|
||||
|
||||
// console.log(`txid: ${JSON.stringify(txid, null, 2)}`)
|
||||
console.log('validateTxid origin: ', origin)
|
||||
// console.log(`validateTxid usrObj: ${JSON.stringify(usrObj, null, 2)}`)
|
||||
|
||||
// Handle a single TXID or an array of TXIDs.
|
||||
let txids
|
||||
@@ -451,7 +451,8 @@ class Utils {
|
||||
const response = await _this.axios.post(
|
||||
path,
|
||||
{
|
||||
txids: txids
|
||||
txids: txids,
|
||||
usrObj // pass user data when making an internal call.
|
||||
},
|
||||
_this.axiosOptions
|
||||
)
|
||||
@@ -650,12 +651,12 @@ class Utils {
|
||||
* '00ea27261196a411776f81029c0ebe34362936b4a9847deb1f7a40a02b3a1476',
|
||||
* valid: true } ]
|
||||
*/
|
||||
async validateTxid3 (txid, origin = null) {
|
||||
async validateTxid3 (txid, usrObj = null) {
|
||||
const path = `${this.restURL}slp/validateTxid3`
|
||||
|
||||
// console.log(`txid: ${JSON.stringify(txid, null, 2)}`)
|
||||
// console.log(`path: ${JSON.stringify(path, null, 2)}`)
|
||||
console.log('origin: ', origin)
|
||||
// console.log('validateTxid3 usrObj: ', usrObj)
|
||||
|
||||
// Handle a single TXID or an array of TXIDs.
|
||||
let txids
|
||||
@@ -667,7 +668,7 @@ class Utils {
|
||||
path,
|
||||
{
|
||||
txids: txids,
|
||||
origin
|
||||
usrObj // pass user data when making an internal call.
|
||||
},
|
||||
_this.axiosOptions
|
||||
)
|
||||
@@ -925,7 +926,7 @@ class Utils {
|
||||
*
|
||||
*/
|
||||
// Reimplementation of decodeOpReturn() using slp-parser.
|
||||
async decodeOpReturn (txid, cache = null) {
|
||||
async decodeOpReturn (txid, cache = null, usrObj = null) {
|
||||
// The cache object is an in-memory cache (JS Object) that can be passed
|
||||
// into this function. It helps if multiple vouts from the same TXID are
|
||||
// being evaluated. In that case, it can significantly reduce the number
|
||||
@@ -942,16 +943,32 @@ class Utils {
|
||||
if (cachedVal) return cachedVal
|
||||
}
|
||||
|
||||
// console.log(`decodeOpReturn usrObj: ${JSON.stringify(usrObj, null, 2)}`)
|
||||
|
||||
try {
|
||||
// Validate the txid input.
|
||||
if (!txid || txid === '' || typeof txid !== 'string') {
|
||||
throw new Error('txid string must be included.')
|
||||
}
|
||||
|
||||
// CT: 2/24/21 Deprected GET in favor of POST, to pass IP address.
|
||||
// Retrieve the transaction object from the full node.
|
||||
const path = `${this.restURL}rawtransactions/getRawTransaction/${txid}?verbose=true`
|
||||
const response = await _this.axios.get(path, _this.axiosOptions)
|
||||
const txDetails = response.data
|
||||
// const path = `${this.restURL}rawtransactions/getRawTransaction/${txid}?verbose=true`
|
||||
// const response = await _this.axios.get(path, _this.axiosOptions)
|
||||
// const txDetails = response.data
|
||||
|
||||
const path = `${this.restURL}rawtransactions/getRawTransaction`
|
||||
const response = await _this.axios.post(
|
||||
path,
|
||||
{
|
||||
verbose: true,
|
||||
txids: [txid],
|
||||
usrObj // pass user data when making an internal call.
|
||||
},
|
||||
_this.axiosOptions
|
||||
)
|
||||
const txDetails = response.data[0]
|
||||
|
||||
// console.log(`txDetails: ${JSON.stringify(txDetails, null, 2)}`)
|
||||
|
||||
// SLP spec expects OP_RETURN to be the first output of the transaction.
|
||||
@@ -998,7 +1015,9 @@ class Utils {
|
||||
|
||||
return tokenData
|
||||
} catch (error) {
|
||||
// console.log('decodeOpReturn error: ', error)
|
||||
console.log('decodeOpReturn error: ', error)
|
||||
console.log(`decodeOpReturn error.message: ${error.message}`)
|
||||
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
throw error
|
||||
}
|
||||
@@ -1064,11 +1083,13 @@ class Utils {
|
||||
// https://github.com/Bitcoin-com/slp-sdk/issues/84
|
||||
|
||||
// CT 5/31/20: Refactored to use slp-parse library.
|
||||
async tokenUtxoDetails (utxos, origin = null) {
|
||||
async tokenUtxoDetails (utxos, usrObj = null) {
|
||||
try {
|
||||
// Throw error if input is not an array.
|
||||
if (!Array.isArray(utxos)) throw new Error('Input must be an array.')
|
||||
|
||||
// console.log(`tokenUtxoDetails usrObj: ${JSON.stringify(usrObj, null, 2)}`)
|
||||
|
||||
// Loop through each element in the array and validate the input before
|
||||
// further processing.
|
||||
for (let i = 0; i < utxos.length; i++) {
|
||||
@@ -1100,7 +1121,7 @@ class Utils {
|
||||
}
|
||||
|
||||
// Hydrate each UTXO with data from SLP OP_REUTRNs.
|
||||
const outAry = await this._hydrateUtxo(utxos)
|
||||
const outAry = await this._hydrateUtxo(utxos, usrObj)
|
||||
// console.log(`outAry: ${JSON.stringify(outAry, null, 2)}`)
|
||||
|
||||
// *After* each UTXO has been hydrated with SLP data,
|
||||
@@ -1116,7 +1137,7 @@ class Utils {
|
||||
// information.
|
||||
|
||||
// Validate using a 'waterfall' of validators.
|
||||
utxo.isValid = await this.waterfallValidateTxid(utxo.txid, origin)
|
||||
utxo.isValid = await this.waterfallValidateTxid(utxo.txid, usrObj)
|
||||
// console.log(`isValid: ${JSON.stringify(utxo.isValid, null, 2)}`)
|
||||
}
|
||||
}
|
||||
@@ -1220,10 +1241,13 @@ class Utils {
|
||||
// This is a private function that is called by tokenUtxoDetails().
|
||||
// It loops through an array of UTXOs and tries to hydrate them with SLP
|
||||
// token information from the OP_RETURN data.
|
||||
async _hydrateUtxo (utxos) {
|
||||
// If this function hits a rate limit... TODO: describe specific behavior.
|
||||
async _hydrateUtxo (utxos, usrObj = null) {
|
||||
try {
|
||||
const decodeOpReturnCache = {}
|
||||
|
||||
// console.log(`_hydrateUtxo usrObj: ${JSON.stringify(usrObj, null, 2)}`)
|
||||
|
||||
// Output Array
|
||||
const outAry = []
|
||||
|
||||
@@ -1236,10 +1260,14 @@ class Utils {
|
||||
// If there is no OP_RETURN, mark the UTXO as false.
|
||||
let slpData = false
|
||||
try {
|
||||
slpData = await this.decodeOpReturn(utxo.txid, decodeOpReturnCache)
|
||||
slpData = await this.decodeOpReturn(
|
||||
utxo.txid,
|
||||
decodeOpReturnCache,
|
||||
usrObj // pass user data when making an internal call.
|
||||
)
|
||||
// console.log(`slpData: ${JSON.stringify(slpData, null, 2)}`)
|
||||
} catch (err) {
|
||||
// console.log(`error from decodeOpReturn(${utxo.txid}): `, err)
|
||||
console.log(`error in _hydrateUtxo() from decodeOpReturn(${utxo.txid}): `, err)
|
||||
|
||||
// An error will be thrown if the txid is not SLP.
|
||||
// If error is for some other reason, like a 429 error, mark utxo as 'null'
|
||||
@@ -1250,10 +1278,10 @@ class Utils {
|
||||
err.message.indexOf('lokad id') === -1 &&
|
||||
err.message.indexOf('trailing data') === -1)
|
||||
) {
|
||||
// console.log(
|
||||
// 'unknown error from decodeOpReturn(). Marking as \'null\'',
|
||||
// err
|
||||
// )
|
||||
console.log(
|
||||
'unknown error from decodeOpReturn(). Marking as \'null\'',
|
||||
err
|
||||
)
|
||||
|
||||
utxo.isValid = null
|
||||
outAry.push(utxo)
|
||||
@@ -1262,7 +1290,7 @@ class Utils {
|
||||
// an SLP UTXO.
|
||||
// Mark as false and continue the loop.
|
||||
} else {
|
||||
// console.log('marking as invalid')
|
||||
console.log('marking as invalid')
|
||||
utxo.isValid = false
|
||||
outAry.push(utxo)
|
||||
}
|
||||
@@ -1326,7 +1354,8 @@ class Utils {
|
||||
|
||||
const genesisData = await this.decodeOpReturn(
|
||||
slpData.tokenId,
|
||||
decodeOpReturnCache
|
||||
decodeOpReturnCache,
|
||||
usrObj // pass user data when making an internal call.
|
||||
)
|
||||
// console.log(`genesisData: ${JSON.stringify(genesisData, null, 2)}`)
|
||||
|
||||
@@ -1378,7 +1407,8 @@ class Utils {
|
||||
|
||||
const genesisData = await this.decodeOpReturn(
|
||||
slpData.tokenId,
|
||||
decodeOpReturnCache
|
||||
decodeOpReturnCache,
|
||||
usrObj // pass user data when making an internal call.
|
||||
)
|
||||
// console.log(`genesisData: ${JSON.stringify(genesisData, null, 2)}`)
|
||||
|
||||
@@ -1412,6 +1442,7 @@ class Utils {
|
||||
|
||||
return outAry
|
||||
} catch (error) {
|
||||
console.log('_hydrateUtxo error: ', error)
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
throw error
|
||||
}
|
||||
@@ -1453,7 +1484,7 @@ class Utils {
|
||||
* // returns
|
||||
* true
|
||||
*/
|
||||
async waterfallValidateTxid (txid, origin = null) {
|
||||
async waterfallValidateTxid (txid, usrObj = null) {
|
||||
try {
|
||||
// console.log('txid: ', txid)
|
||||
|
||||
@@ -1485,7 +1516,7 @@ class Utils {
|
||||
// validateTxid2() uses slp-validate, which has a different output format.
|
||||
|
||||
// Validate against the whitelist SLPDB first.
|
||||
const whitelistResult = await this.validateTxid3(txid, origin)
|
||||
const whitelistResult = await this.validateTxid3(txid, usrObj)
|
||||
// console.log(
|
||||
// `whitelist-SLPDB for ${txid}: ${JSON.stringify(
|
||||
// whitelistResult,
|
||||
@@ -1506,7 +1537,7 @@ class Utils {
|
||||
}
|
||||
|
||||
// Try the general SLPDB, if the whitelist returned null.
|
||||
const generalResult = await this.validateTxid(txid, origin)
|
||||
const generalResult = await this.validateTxid(txid, usrObj)
|
||||
// console.log(
|
||||
// `validateTxid() isValid: ${JSON.stringify(generalResult, null, 2)}`
|
||||
// )
|
||||
|
||||
+18
-18
@@ -273,8 +273,8 @@ describe('#SLP Utils', () => {
|
||||
try {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.nonSLPTxDetailsWithoutOpReturn })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.nonSLPTxDetailsWithoutOpReturn] })
|
||||
|
||||
const txid =
|
||||
'3793d4906654f648e659f384c0f40b19c8f10c1e9fb72232a9b8edd61abaa1ec'
|
||||
@@ -292,8 +292,8 @@ describe('#SLP Utils', () => {
|
||||
try {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.nonSLPTxDetailsWithOpReturn })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.nonSLPTxDetailsWithOpReturn] })
|
||||
|
||||
const txid =
|
||||
'2ff74c48a5d657cf45f699601990bffbbe7a2a516d5480674cbf6c6a4497908f'
|
||||
@@ -310,8 +310,8 @@ describe('#SLP Utils', () => {
|
||||
it('should decode a genesis transaction', async () => {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPGenesis })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPGenesis] })
|
||||
|
||||
const txid =
|
||||
'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90'
|
||||
@@ -336,8 +336,8 @@ describe('#SLP Utils', () => {
|
||||
it('should decode a mint transaction', async () => {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPMint })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPMint] })
|
||||
|
||||
const txid =
|
||||
'65f21bbfcd545e5eb515e38e861a9dfe2378aaa2c4e458eb9e59e4d40e38f3a4'
|
||||
@@ -357,8 +357,8 @@ describe('#SLP Utils', () => {
|
||||
it('should decode a send transaction', async () => {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPSend })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPSend] })
|
||||
|
||||
const txid =
|
||||
'4f922565af664b6fdf0a1ba3924487344be721b3d8815c62cafc8a51e04a8afa'
|
||||
@@ -372,8 +372,8 @@ describe('#SLP Utils', () => {
|
||||
it('should properly decode a Genesis transaction with no minting baton', async () => {
|
||||
// Mock the call to the REST API.
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPGenesisNoBaton })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPGenesisNoBaton] })
|
||||
|
||||
const txid =
|
||||
'497291b8a1dfe69c8daea50677a3d31a5ef0e9484d8bebb610dac64bbc202fb7'
|
||||
@@ -387,8 +387,8 @@ describe('#SLP Utils', () => {
|
||||
it('should decode a send transaction with alternate encoding', async () => {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPSendAlt })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPSendAlt] })
|
||||
|
||||
const txid =
|
||||
'd94357179775425ebc59c93173bd6dc9854095f090a2eb9dcfe9797398bc8eae'
|
||||
@@ -411,8 +411,8 @@ describe('#SLP Utils', () => {
|
||||
try {
|
||||
// Mock the call to the REST API
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.mockInvalidSlpSend })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.mockInvalidSlpSend] })
|
||||
|
||||
const txid =
|
||||
'a60a522cc11ad7011b74e57fbabbd99296e4b9346bcb175dcf84efb737030415'
|
||||
@@ -428,8 +428,8 @@ describe('#SLP Utils', () => {
|
||||
it('should decode a NFT Parent transaction', async () => {
|
||||
// Mock the call to the REST API.
|
||||
sandbox
|
||||
.stub(uut.Utils.axios, 'get')
|
||||
.resolves({ data: mockData.txDetailsSLPNftGenesis })
|
||||
.stub(uut.Utils.axios, 'post')
|
||||
.resolves({ data: [mockData.txDetailsSLPNftGenesis] })
|
||||
|
||||
const txid =
|
||||
'4ef6eb92950a13a69e97c2c02c7967d806aa874c0e2a6b5546a8880f2cd14bc4'
|
||||
|
||||
Reference in New Issue
Block a user