Handle OP_RETURN OP_PUSHDATA2 type output
This commit is contained in:
parent
02369a9cce
commit
538ff0cdcb
@ -4,9 +4,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"unicode/utf8"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
|
||||
vlq "github.com/bsm/go-vlq"
|
||||
"github.com/juju/errors"
|
||||
@ -140,6 +140,7 @@ func (p *BitcoinParser) TryParseOPReturn(script []byte) string {
|
||||
// trying 2 variants of OP_RETURN data
|
||||
// 1) OP_RETURN OP_PUSHDATA1 <datalen> <data>
|
||||
// 2) OP_RETURN <datalen> <data>
|
||||
// 3) OP_RETURN OP_PUSHDATA2 <datalenlow> <datalenhigh> <data>
|
||||
var data []byte
|
||||
var l int
|
||||
if script[1] == txscript.OP_PUSHDATA1 && len(script) > 2 {
|
||||
@ -149,6 +150,9 @@ func (p *BitcoinParser) TryParseOPReturn(script []byte) string {
|
||||
l = int(script[1])
|
||||
data = script[2:]
|
||||
}
|
||||
} else if script[1] == txscript.OP_PUSHDATA2 && len(script) > 3 {
|
||||
l = int(script[2]) + int(script[3])<<8
|
||||
data = script[4:]
|
||||
} else {
|
||||
l = int(script[1])
|
||||
data = script[2:]
|
||||
|
||||
@ -208,6 +208,55 @@ func TestGetAddressesFromAddrDesc(t *testing.T) {
|
||||
want2: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "OP_RETURN OP_PUSHDATA1 utf8",
|
||||
args: args{script: "6a31e5bfabe981a9e381ab4254434658e58f96e5bc95e3818ce381a7e3818de3828b5043e3818ce6acb2e38197e38184e38082"},
|
||||
want: []string{"OP_RETURN (快適にBTCFX取引ができるPCが欲しい。)"},
|
||||
want2: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "OP_RETURN OP_PUSHDATA2 ascii",
|
||||
args: args{script: "6a4dd7035765277265206e6f20737472616e6765727320746f206c6f76650a596f75206b6e6f77207468652072756c657320616e6420736f20646f20490a412066756c6c20636f6d6d69746d656e74277320776861742049276d207468696e6b696e67206f660a596f7520776f756c646e27742067657420746869732066726f6d20616e79206f74686572206775790a49206a7573742077616e6e612074656c6c20796f7520686f772049276d206665656c696e670a476f747461206d616b6520796f7520756e6465727374616e640a0a43484f5255530a4e6576657220676f6e6e61206769766520796f752075702c0a4e6576657220676f6e6e61206c657420796f7520646f776e0a4e6576657220676f6e6e612072756e2061726f756e6420616e642064657365727420796f750a4e6576657220676f6e6e61206d616b6520796f75206372792c0a4e6576657220676f6e6e612073617920676f6f646279650a4e6576657220676f6e6e612074656c6c2061206c696520616e64206875727420796f750a0a5765277665206b6e6f776e2065616368206f7468657220666f7220736f206c6f6e670a596f75722068656172742773206265656e20616368696e672062757420796f7527726520746f6f2073687920746f207361792069740a496e7369646520776520626f7468206b6e6f7720776861742773206265656e20676f696e67206f6e0a5765206b6e6f77207468652067616d6520616e6420776527726520676f6e6e6120706c61792069740a416e6420696620796f752061736b206d6520686f772049276d206665656c696e670a446f6e27742074656c6c206d6520796f7527726520746f6f20626c696e6420746f20736565202843484f525553290a0a43484f52555343484f5255530a284f6f68206769766520796f75207570290a284f6f68206769766520796f75207570290a284f6f6829206e6576657220676f6e6e6120676976652c206e6576657220676f6e6e6120676976650a286769766520796f75207570290a284f6f6829206e6576657220676f6e6e6120676976652c206e6576657220676f6e6e6120676976650a286769766520796f75207570290a0a5765277665206b6e6f776e2065616368206f7468657220666f7220736f206c6f6e670a596f75722068656172742773206265656e20616368696e672062757420796f7527726520746f6f2073687920746f207361792069740a496e7369646520776520626f7468206b6e6f7720776861742773206265656e20676f696e67206f6e0a5765206b6e6f77207468652067616d6520616e6420776527726520676f6e6e6120706c61792069742028544f2046524f4e54290a0a"},
|
||||
want: []string{`OP_RETURN (We're no strangers to love
|
||||
You know the rules and so do I
|
||||
A full commitment's what I'm thinking of
|
||||
You wouldn't get this from any other guy
|
||||
I just wanna tell you how I'm feeling
|
||||
Gotta make you understand
|
||||
|
||||
CHORUS
|
||||
Never gonna give you up,
|
||||
Never gonna let you down
|
||||
Never gonna run around and desert you
|
||||
Never gonna make you cry,
|
||||
Never gonna say goodbye
|
||||
Never gonna tell a lie and hurt you
|
||||
|
||||
We've known each other for so long
|
||||
Your heart's been aching but you're too shy to say it
|
||||
Inside we both know what's been going on
|
||||
We know the game and we're gonna play it
|
||||
And if you ask me how I'm feeling
|
||||
Don't tell me you're too blind to see (CHORUS)
|
||||
|
||||
CHORUSCHORUS
|
||||
(Ooh give you up)
|
||||
(Ooh give you up)
|
||||
(Ooh) never gonna give, never gonna give
|
||||
(give you up)
|
||||
(Ooh) never gonna give, never gonna give
|
||||
(give you up)
|
||||
|
||||
We've known each other for so long
|
||||
Your heart's been aching but you're too shy to say it
|
||||
Inside we both know what's been going on
|
||||
We know the game and we're gonna play it (TO FRONT)
|
||||
|
||||
)`},
|
||||
want2: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "OP_RETURN hex",
|
||||
args: args{script: "6a072020f1686f6a20"},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user