decode

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTxDecode is returned if we cannot parse a transaction
	ErrTxDecode     = errors.Register(txCodespace, 1, "tx parse error")
	ErrUnknownField = errors.Register(txCodespace, 2, "unknown protobuf field")
)

Functions

func RejectUnknownFields

func RejectUnknownFields(bz []byte, desc protoreflect.MessageDescriptor, allowUnknownNonCriticals bool, resolver protodesc.Resolver) (hasUnknownNonCriticals bool, err error)

RejectUnknownFields rejects any bytes bz with an error that has unknown fields for the provided proto.Message type with an option to allow non-critical fields (specified as those fields with bit 11) to pass through. In either case, the hasUnknownNonCriticals will be set to true if non-critical fields were encountered during traversal. This flag can be used to treat a message with non-critical field different in different security contexts (such as transaction signing). This function traverses inside of messages nested via google.protobuf.Any. It does not do any deserialization of the proto.Message. An AnyResolver must be provided for traversing inside google.protobuf.Any's.

func RejectUnknownFieldsStrict

func RejectUnknownFieldsStrict(bz []byte, msg protoreflect.MessageDescriptor, resolver protodesc.Resolver) error

RejectUnknownFieldsStrict operates by the same rules as RejectUnknownFields, but returns an error if any unknown non-critical fields are encountered.

func WireTypeToString

func WireTypeToString(wt protowire.Type) string

WireTypeToString returns a string representation of the given protowire.Type.

Types

type DecodedTx added in v0.5.1

type DecodedTx struct {
	DynamicMessages              []proto.Message
	Messages                     []gogoproto.Message
	Tx                           *v1beta1.Tx
	TxRaw                        *v1beta1.TxRaw
	Signers                      [][]byte
	TxBodyHasUnknownNonCriticals bool
	// contains filtered or unexported fields
}

DecodedTx contains the decoded transaction, its signers, and other flags.

func (*DecodedTx) Bytes added in v1.0.1

func (dtx *DecodedTx) Bytes() []byte

func (*DecodedTx) GetGasLimit added in v1.0.1

func (dtx *DecodedTx) GetGasLimit() (uint64, error)

func (*DecodedTx) GetMessages added in v1.0.1

func (dtx *DecodedTx) GetMessages() ([]Msg, error)

func (*DecodedTx) GetSenders added in v1.0.1

func (dtx *DecodedTx) GetSenders() ([][]byte, error)

func (*DecodedTx) Hash added in v1.0.1

func (dtx *DecodedTx) Hash() [32]byte

Hash implements the interface for the Tx interface.

type Decoder added in v0.5.1

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder contains the dependencies required for decoding transactions.

func NewDecoder added in v0.5.1

func NewDecoder(options Options) (*Decoder, error)

NewDecoder creates a new Decoder for decoding transactions.

func (*Decoder) Decode added in v0.5.1

func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error)

Decode decodes raw protobuf encoded transaction bytes into a DecodedTx.

type Msg added in v1.0.1

type Msg = interface {
	Reset()
	String() string
	ProtoMessage()
}

type Options added in v0.5.1

type Options struct {
	SigningContext *signing.Context
	ProtoCodec     gogoProtoCodec
}

Options are options for creating a Decoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳