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"
}
}
]
}
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?
Closing in favour of https://github.com/bitcoinjs/bitcoinjs-lib/issues/778
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?
Most helpful comment
I'm using version 2.3.0 since the readme clearly states:
:-)