From f5cb035996327deac157c7d8a0fb8d4def70c090 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 26 Jun 2020 11:07:27 +0300 Subject: [PATCH] keys: support returning legacy verification script When one works with legacy (NEO2) wallets, it is useful to have access to old verification script formats. --- pkg/crypto/keys/publickey.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/crypto/keys/publickey.go b/pkg/crypto/keys/publickey.go index d03bdb22b..948b589f3 100644 --- a/pkg/crypto/keys/publickey.go +++ b/pkg/crypto/keys/publickey.go @@ -242,6 +242,12 @@ func (p *PublicKey) EncodeBinary(w *io.BinWriter) { func (p *PublicKey) GetVerificationScript() []byte { b := p.Bytes() buf := io.NewBufBinWriter() + if address.Prefix == address.NEO2Prefix { + buf.WriteB(0x21) // PUSHBYTES33 + buf.WriteBytes(p.Bytes()) + buf.WriteB(0xAC) // CHECKSIG + return buf.Bytes() + } emit.Bytes(buf.BinWriter, b) emit.Opcode(buf.BinWriter, opcode.PUSHNULL) emit.Syscall(buf.BinWriter, "Neo.Crypto.ECDsaVerify")