binarycodec

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 11 Imported by: 2

README

Binary Codec

This package contains functions to encode/decode to/from the ripple binary serialization format.

API

Encode
encoded, err := binarycodec.Encode(jsonObject)
Decode
json, err := binarycodec.Decode(hexEncodedString)
EncodeForMultisigning
encoded, err := binarycodec.EncodeForMultisigning(jsonObject, xrpAccountID)
EncodeForSigning
encoded, err := binarycodec.EncodeForSigning(jsonObject)
EncodeForSigningClaim
encoded, err := binarycodec.EncodeForSigningClaim(jsonObject)
EncodeQuality
encoded, err := binarycodec.EncodeQuality(amountString)
DecodeQuality
decoded, err := binarycodec.DecodeQuality(encoded)
DecodeLedgerData
ledgerData, err := binarycodec.DecodeLedgerData(hexEncodedString)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrSigningClaimFieldNotFound is returned when the 'Channel' & 'Amount' fields are both required, but were not found.
	ErrSigningClaimFieldNotFound = errors.New("'Channel' & 'Amount' fields are both required, but were not found")
	// ErrBatchFlagsFieldNotFound is returned when the 'flags' field is missing.
	ErrBatchFlagsFieldNotFound = errors.New("no field `flags`")
	// ErrBatchTxIDsFieldNotFound is returned when the 'txIDs' field is missing.
	ErrBatchTxIDsFieldNotFound = errors.New("no field `txIDs`")
	// ErrBatchTxIDsNotArray is returned when the 'txIDs' field is not an array.
	ErrBatchTxIDsNotArray = errors.New("txIDs field must be an array")
	// ErrBatchTxIDNotString is returned when a txID is not a string.
	ErrBatchTxIDNotString = errors.New("each txID must be a string")
	// ErrBatchFlagsNotUInt32 is returned when the 'flags' field is not a uint32.
	ErrBatchFlagsNotUInt32 = errors.New("flags field must be a uint32")
	// ErrBatchTxIDsLengthTooLong is returned when the 'txIDs' field is too long.
	ErrBatchTxIDsLengthTooLong = errors.New("txIDs length exceeds maximum uint32 value")
)
View Source
var (

	// ErrInvalidQuality is returned when the quality is invalid.
	ErrInvalidQuality = errors.New("invalid quality")
)

Functions

func Decode

func Decode(hexEncoded string) (map[string]any, error)

Decode decodes a hex string in the canonical binary format into a JSON transaction object.

func DecodeQuality

func DecodeQuality(quality string) (string, error)

Decode a quality amount from a hex string to a string.

func Encode

func Encode(json map[string]any) (string, error)

Encode converts a JSON transaction object to a hex string in the canonical binary format. The binary format is defined in XRPL's core codebase.

func EncodeForMultisigning

func EncodeForMultisigning(json map[string]any, xrpAccountID string) (string, error)

EncodeForMultiSign: encodes a transaction into binary format in preparation for providing one signature towards a multi-signed transaction. (Only encodes fields that are intended to be signed.)

func EncodeForSigning

func EncodeForSigning(json map[string]any) (string, error)

Encodes a transaction into binary format in preparation for signing.

func EncodeForSigningBatch added in v0.1.11

func EncodeForSigningBatch(json map[string]any) (string, error)

EncodeForSigningBatch encodes a batch transaction into binary format in preparation for signing.

func EncodeForSigningClaim

func EncodeForSigningClaim(json map[string]any) (string, error)

EncodeForPaymentChannelClaim: encodes a payment channel claim into binary format in preparation for signing.

func EncodeQuality

func EncodeQuality(quality string) (string, error)

EncodeQuality encodes a quality amount to a hex string.

Types

type LedgerData

type LedgerData struct {
	LedgerIndex         uint32
	TotalCoins          string
	ParentHash          string
	TransactionHash     string
	AccountHash         string
	ParentCloseTime     uint32
	CloseTime           uint32
	CloseTimeResolution uint8
	CloseFlags          uint8
}

LedgerData represents the data of a ledger.

func DecodeLedgerData

func DecodeLedgerData(data string) (LedgerData, error)

DecodeLedgerData decodes a hex string in the canonical binary format into a LedgerData object. The hex string should represent a ledger data object.

Directories

Path Synopsis
testutil
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.
testutil
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.

Jump to

Keyboard shortcuts

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