Bitcoinjs-lib: Unable to decode transaction

Created on 8 Mar 2017  路  7Comments  路  Source: bitcoinjs/bitcoinjs-lib

I'm working with regtest and I'm unable to decode a coinbase transaction, this is the code:

const Bitcoin = require('bitcoinjs-lib')

var buf = new Buffer('020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff05022b020101ffffffff02c0cf402500000000232103c6c5964853fd00fb3271ac002831c66825102d223c706ce0ee99e73db3be4aa1ac0000000000000000266a24aa21a9edff828eb21f40ab251d9f107792670aba9299028b894a364fda570f6a089dcfe90120000000000000000000000000000000000000000000000000000000000000000000000000', 'hex')
const tx = Bitcoin.Transaction.fromBuffer(buf)

The error is:

if (offset !== buffer.length) throw new Error('Transaction has unexpected data')
^
Error: Transaction has unexpected data
at Function.Transaction.fromBuffer (/Work/Bitcoin/cm-js/node_modules/bitcoinjs-lib/src/transaction.js:75:39)

But the transaction is fine:

$ bitcoin-cli decoderawtransaction 020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff05022b020101ffffffff02c0cf402500000000232103c6c5964853fd00fb3271ac002831c66825102d223c706ce0ee99e73db3be4aa1ac0000000000000000266a24aa21a9edff828eb21f40ab251d9f107792670aba9299028b894a364fda570f6a089dcfe90120000000000000000000000000000000000000000000000000000000000000000000000000

{
  "txid": "c881f7b084a367b0603abbcb9c5c639318e6166770e3f9b27a1ee3f8b6a16517",
  "hash": "b3a295ad426c1d2bb818697e6092308b224721d0f0c094b3c9846c15f5e46d42",
  "size": 183,
  "vsize": 156,
  "version": 2,
  "locktime": 0,
  "vin": [
    {
      "coinbase": "022b020101",
      "txinwitness": [
        "0000000000000000000000000000000000000000000000000000000000000000"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 6.25004480,
      "n": 0,
      "scriptPubKey": {
        "asm": "03c6c5964853fd00fb3271ac002831c66825102d223c706ce0ee99e73db3be4aa1 OP_CHECKSIG",
        "hex": "2103c6c5964853fd00fb3271ac002831c66825102d223c706ce0ee99e73db3be4aa1ac",
        "reqSigs": 1,
        "type": "pubkey",
        "addresses": [
          "mjEacF6hRqEjahE2ENFK4ofJneab6wxvca"
        ]
      }
    },
    {
      "value": 0.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_RETURN aa21a9edff828eb21f40ab251d9f107792670aba9299028b894a364fda570f6a089dcfe9",
        "hex": "6a24aa21a9edff828eb21f40ab251d9f107792670aba9299028b894a364fda570f6a089dcfe9",
        "type": "nulldata"
      }
    }
  ]
}
how to / question / docs

Most helpful comment

I'm using version 2.3.0 since the readme clearly states:

If you are thinking of using the master branch of this library in production, stop

:-)

All 7 comments

Are you using master?

Can't reproduce on master.
See https://github.com/bitcoinjs/bitcoinjs-lib/pull/765 for a reference.

@afk11 we need to release asap. :+1:
Is there anything holding us back?
Are you able to help with the CHANGELOG?

I'm using version 2.3.0 since the readme clearly states:

If you are thinking of using the master branch of this library in production, stop

:-)

I'll go over the commits and push release notes somewhere for you! I'd ask about tagging, but you'll be awake soon :)

Someone can explain me why this coinbase transaction has a zero output with an op return?

Someone can explain me why this coinbase transaction has a zero output with an op return?

Not without further investigation which I don't have the time for.
It is testnet, it may be someone testing an idea?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yakitorifoodie picture yakitorifoodie  路  3Comments

itsMikeLowrey picture itsMikeLowrey  路  3Comments

dakk picture dakk  路  3Comments

Beardcoding picture Beardcoding  路  3Comments

silence-may picture silence-may  路  3Comments