vm: add address&swap endianness to opcode dump for hashes
If the parameter in the opcode dump is a 20-byte value, the converted values, such as the address and the swapped endianness, have been added. Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
This commit is contained in:
parent
5180305240
commit
259cbc3356
1 changed files with 10 additions and 1 deletions
|
@ -3,6 +3,7 @@ package vm
|
|||
import (
|
||||
"crypto/elliptic"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -15,6 +16,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||
|
@ -216,11 +218,18 @@ func (v *VM) PrintOps(out io.Writer) {
|
|||
default:
|
||||
if utf8.Valid(parameter) {
|
||||
desc = fmt.Sprintf("%x (%q)", parameter, parameter)
|
||||
} else {
|
||||
// Try converting the parameter to an address and swap the endianness
|
||||
// if the parameter is a 20-byte value.
|
||||
u, err := util.Uint160DecodeBytesBE(parameter)
|
||||
if err == nil {
|
||||
desc = fmt.Sprintf("%x (%q, %q)", parameter, address.Uint160ToString(u), "0x"+hex.EncodeToString(slice.CopyReverse(parameter)))
|
||||
} else {
|
||||
desc = fmt.Sprintf("%x", parameter)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%d\t%s\t%s%s\n", ctx.ip, instr, desc, cursor)
|
||||
if ctx.nextip >= len(ctx.sc.prog) {
|
||||
|
|
Loading…
Reference in a new issue