diff --git a/src/transaction.js b/src/transaction.js index edc1372..1e9f26b 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -102,6 +102,7 @@ class Transaction { // Loop through each input and retrieve the token data. for (let i = 0; i < txDetails.vin.length; i++) { const thisVin = txDetails.vin[i] + // console.log(`thisVin: ${JSON.stringify(thisVin, null, 2)}`) try { // If decodeOpReturn() throws an error, then this input is not @@ -168,6 +169,9 @@ class Transaction { thisVin.tokenQtyStr = realQty thisVin.tokenQty = parseFloat(realQty) // txDetails.vin[i].tokenQty = tokenQty + + // Add token ID to input + thisVin.tokenId = inTokenData.tokenId } else { thisVin.tokenQty = null } @@ -183,6 +187,9 @@ class Transaction { // Finally, validate the SLP TX. // this.slpUtils.waterfallValidateTxid(txid, usrObj) txDetails.isValidSLPTx = await this.slpUtils.waterfallValidateTxid(txid) + + // TODO: Convert the block hash to a block height. Add block height + // value to the transaction. } catch (err) { // console.log('Error: ', err) diff --git a/test/integration/transaction-integration.js b/test/integration/transaction-integration.js index 3a924b8..0e2dcd2 100644 --- a/test/integration/transaction-integration.js +++ b/test/integration/transaction-integration.js @@ -56,5 +56,26 @@ describe('#Transaction', () => { assert.property(result, 'isValidSLPTx') assert.equal(result.isValidSLPTx, true) }) + + // it('should get problematic transaction', async () => { + // const txid = 'a55515de32577e296c512840bcaabed5823bb773fb4f8fd8e5197cc96cbc54d1' + // + // const result = await bchjs.Transaction.get(txid) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) + // }) + + // TX a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe has + // an input TXID (bd84bc1dd5ecd976165892306992401272f6bedeb37d7b2cdbf74fc4a55967a6) + // that is also a valid SLP tx, but is unrelated. Both TXs pass DAG validation, + // but for separate tokens. + it('should get problematic transaction', async () => { + const txid = 'a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe' + + const result = await bchjs.Transaction.get(txid) + // console.log(`result: ${JSON.stringify(result, null, 2)}`) + + // The token ID should equal the txid for this Vin. + assert.equal(result.vin[2].txid, result.vin[2].tokenId) + }) }) })