This assumes OP_RETURN then PUSHDATA (1 Byte) and slices 2 bytes off the head.
If you push 77 bytes, the PUSHDATA is 2 bytes long, so decode will give the second byte of the PUSHDATA on the head of the decoded buffer.
Since OP_RETURN allows for multiple pushes as long as the scriptPubkey is 80 bytes or lower, the decode should be
@junderw could you submit a PR that uses .decompile and returns stack[1]?
And could you add a test fixture?
Sure. But wouldn't that just return the data of the first push?
ex:
> var b = require('bitcoinjs-lib')
> b.script.decompile(Buffer.from('6a010202030403040304','hex'))
[ 106, <Buffer 02>, <Buffer 03 04>, <Buffer 04 03 04> ]
// stack[1] === <Buffer 02>
I am wondering whether the result of bscript.nullData.output.decode should be
A: [ <Buffer 02>, <Buffer 03 04>, <Buffer 04 03 04> ]
B: <Buffer 01 02 02 03 04 03 04 03 04>
The rules for standardness are:
Maybe .compile(bscript.decompile(buffer).slice(1))?
I'll see if I can't put up some fixtures and fix it.
I'm working on it. I'm also going to modify encode a little.
Closing in favour of #859