Merge pull request #84 from Permissionless-Software-Foundation/ct-unstable

fix(tokenUtxoDetails): Removing requirement to provide satoshis or va…
This commit is contained in:
Chris Troutner
2021-01-09 15:45:43 -08:00
committed by GitHub
2 changed files with 46 additions and 44 deletions
+12 -11
View File
@@ -1073,17 +1073,18 @@ class Utils {
for (let i = 0; i < utxos.length; i++) { for (let i = 0; i < utxos.length; i++) {
const utxo = utxos[i] const utxo = utxos[i]
if (!utxo.satoshis) { // CT 1/9/21: This code can be removed after 2/1/21
// If Electrumx, convert the value to satoshis. // if (!utxo.satoshis) {
if (utxo.value) { // // If Electrumx, convert the value to satoshis.
utxo.satoshis = utxo.value // if (utxo.value) {
} else { // utxo.satoshis = utxo.value
// If there is neither a satoshis or value property, throw an error. // } else {
throw new Error( // // If there is neither a satoshis or value property, throw an error.
`utxo ${i} does not have a satoshis or value property.` // throw new Error(
) // `utxo ${i} does not have a satoshis or value property.`
} // )
} // }
// }
if (!utxo.txid) { if (!utxo.txid) {
// If Electrumx, convert the tx_hash property to txid. // If Electrumx, convert the tx_hash property to txid.
+34 -33
View File
@@ -497,39 +497,40 @@ describe('#SLP Utils', () => {
} }
}) })
it('should throw error if utxo does not have satoshis or value property.', async () => { // CT 1/9/21: This test can be removed after 2/1/21
try { // it('should throw error if utxo does not have satoshis or value property.', async () => {
const utxos = [ // try {
{ // const utxos = [
txid: // {
'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90', // txid:
vout: 3, // 'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90',
amount: 0.00002015, // vout: 3,
satoshis: 2015, // amount: 0.00002015,
height: 594892, // satoshis: 2015,
confirmations: 5 // height: 594892,
}, // confirmations: 5
{ // },
txid: // {
'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90', // txid:
vout: 2, // 'bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90',
amount: 0.00000546, // vout: 2,
height: 594892, // amount: 0.00000546,
confirmations: 5 // height: 594892,
} // confirmations: 5
] // }
// ]
await uut.Utils.tokenUtxoDetails(utxos) //
// await uut.Utils.tokenUtxoDetails(utxos)
assert.equal(true, false, 'Unexpected result.') //
} catch (err) { // assert.equal(true, false, 'Unexpected result.')
assert.include( // } catch (err) {
err.message, // assert.include(
'utxo 1 does not have a satoshis or value property', // err.message,
'Expected error message.' // 'utxo 1 does not have a satoshis or value property',
) // 'Expected error message.'
} // )
}) // }
// })
it('should throw error if utxo does not have txid or tx_hash property.', async () => { it('should throw error if utxo does not have txid or tx_hash property.', async () => {
try { try {