decode

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 12 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 {
	Messages                     []proto.Message
	Tx                           *v1beta1.Tx
	TxRaw                        *v1beta1.TxRaw
	Signers                      [][]byte
	TxBodyHasUnknownNonCriticals bool
}

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

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 Options added in v0.5.1

type Options struct {
	SigningContext *signing.Context
}

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