Help us shape the future of Go! Take the 2026 Go Developer Survey

tx

package
v1.36.185 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: BSD-3-Clause Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Export

type Export struct {
	// ChainID provides cross chain replay protection
	ChainID ids.ID `json:"chainID"`
	// Nonce provides internal chain replay protection
	Nonce       uint64      `json:"nonce"`
	MaxFee      uint64      `json:"maxFee"`
	PeerChainID ids.ID      `json:"peerChainID"`
	IsReturn    bool        `json:"isReturn"`
	Amount      uint64      `json:"amount"`
	To          ids.ShortID `json:"to"`
}

func (*Export) Marshal added in v1.36.3

func (e *Export) Marshal() ([]byte, error)

Marshal encodes the Export as one native ZAP object with the tx kind byte at offset 0.

func (*Export) Visit

func (e *Export) Visit(v Visitor) error

type Import

type Import struct {
	// Nonce provides internal chain replay protection
	Nonce  uint64 `json:"nonce"`
	MaxFee uint64 `json:"maxFee"`
	// Message includes the chainIDs to provide cross chain replay protection
	Message []byte `json:"message"`
}

func (*Import) Marshal added in v1.36.3

func (i *Import) Marshal() ([]byte, error)

Marshal encodes the Import as one native ZAP object with the tx kind byte at offset 0.

func (*Import) Visit

func (i *Import) Visit(v Visitor) error

type Payload

type Payload struct {
	// Sender + Nonce provides replay protection
	Sender   ids.ShortID `json:"sender"`
	Nonce    uint64      `json:"nonce"`
	IsReturn bool        `json:"isReturn"`
	Amount   uint64      `json:"amount"`
	To       ids.ShortID `json:"to"`
	// contains filtered or unexported fields
}

func NewPayload

func NewPayload(
	sender ids.ShortID,
	nonce uint64,
	isReturn bool,
	amount uint64,
	to ids.ShortID,
) (*Payload, error)

func ParsePayload

func ParsePayload(bytes []byte) (*Payload, error)

func (*Payload) Bytes

func (p *Payload) Bytes() []byte

type Transfer

type Transfer struct {
	// ChainID provides cross chain replay protection
	ChainID ids.ID `json:"chainID"`
	// Nonce provides internal chain replay protection
	Nonce   uint64      `json:"nonce"`
	MaxFee  uint64      `json:"maxFee"`
	AssetID ids.ID      `json:"assetID"`
	Amount  uint64      `json:"amount"`
	To      ids.ShortID `json:"to"`
}

func (*Transfer) Marshal added in v1.36.3

func (t *Transfer) Marshal() ([]byte, error)

Marshal encodes the Transfer as one native ZAP object with the tx kind byte at offset 0.

func (*Transfer) Visit

func (t *Transfer) Visit(v Visitor) error

type Tx

type Tx struct {
	Unsigned  `json:"unsigned"`
	Signature [secp256k1.SignatureLen]byte `json:"signature"`
}

func Parse

func Parse(bytes []byte) (*Tx, error)

func Sign

func Sign(utx Unsigned, key *secp256k1.PrivateKey) (*Tx, error)

func (*Tx) ID

func (tx *Tx) ID() (ids.ID, error)

func (*Tx) Marshal added in v1.36.3

func (tx *Tx) Marshal() ([]byte, error)

Marshal encodes the signed tx: the unsigned tx bytes (self-describing via its own kind byte) plus the fixed signature.

func (*Tx) SenderID

func (tx *Tx) SenderID() (ids.ShortID, error)

type Unsigned

type Unsigned interface {
	Visit(Visitor) error

	// Marshal encodes the unsigned tx to its native ZAP wire form. The first
	// object byte is the tx kind discriminator — this is the whole dispatch,
	// no codec.
	Marshal() ([]byte, error)
}

type Visitor

type Visitor interface {
	Transfer(*Transfer) error
	Export(*Export) error
	Import(*Import) error
}

Jump to

Keyboard shortcuts

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