owner

package
v1.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const NEO3WalletSize = 25

NEO3WalletSize contains size of neo3 wallet.

Variables

View Source
var ErrEmptyPublicKey = errors.New("empty public key")

ErrEmptyPublicKey when public key passed to Verify method is nil.

Functions

func PublicKeyToIDBytes

func PublicKeyToIDBytes(pub *ecdsa.PublicKey) []byte

PublicKeyToIDBytes converts public key to a byte slice of NEO3WalletSize length. It is similar to decoding a NEO3 address but is inlined to skip base58 encoding-decoding step make it clear that no errors can occur.

func ScriptHashToIDBytes

func ScriptHashToIDBytes(sh util.Uint160) []byte

ScriptHashToIDBytes converts NEO3 script hash to a byte slice of NEO3WalletSize length.

Types

type ID

type ID refs.OwnerID

ID represents v2-compatible owner identifier.

func NewID

func NewID() *ID

NewID creates and initializes blank ID.

Works similar as NewIDFromV2(new(OwnerID)).

Defaults:

  • value: nil.

func NewIDFromN3Account

func NewIDFromN3Account(acc *wallet.Account) *ID

NewIDFromN3Account creates new owner identity from N3 wallet account.

func NewIDFromPublicKey

func NewIDFromPublicKey(pub *ecdsa.PublicKey) *ID

NewIDFromPublicKey creates new owner identity from ECDSA public key.

func NewIDFromV2

func NewIDFromV2(idV2 *refs.OwnerID) *ID

NewIDFromV2 wraps v2 OwnerID message to ID.

Nil refs.OwnerID converts to nil.

func (*ID) Equal

func (id *ID) Equal(id2 *ID) bool

Equal defines a comparison relation on ID's.

ID's are equal if they have the same binary representation.

func (*ID) Marshal

func (id *ID) Marshal() ([]byte, error)

Marshal marshals ID into a protobuf binary form.

func (*ID) MarshalJSON

func (id *ID) MarshalJSON() ([]byte, error)

MarshalJSON encodes ID to protobuf JSON format.

func (*ID) Parse

func (id *ID) Parse(s string) error

Parse converts base58 string representation into ID.

func (*ID) SetPublicKey

func (id *ID) SetPublicKey(pub *ecdsa.PublicKey)

SetPublicKey sets owner identifier value to the provided NEO3 public key.

func (*ID) SetScriptHash

func (id *ID) SetScriptHash(u util.Uint160)

SetScriptHash sets owner identifier value to the provided NEO3 script hash.

func (*ID) String

func (id *ID) String() string

String implements fmt.Stringer.

func (*ID) ToV2

func (id *ID) ToV2() *refs.OwnerID

ToV2 returns the v2 owner ID message.

Nil ID converts to nil.

func (*ID) Unmarshal

func (id *ID) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of ID.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes ID from protobuf JSON format.

func (*ID) Valid

func (id *ID) Valid() bool

Valid returns true if id is a valid owner id. The rules for v2 are the following: 1. Must be 25 bytes in length. 2. Must have N3 address prefix-byte. 3. Last 4 bytes must contain the address checksum.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL