stellar

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//VersionByteAccountID is the version byte used for encoded stellar addresses
	VersionByteAccountID VersionByte = 6 << 3 // Base32-encodes to 'G...'

	//VersionByteSeed is the version byte used for encoded stellar seed
	VersionByteSeed = 18 << 3 // Base32-encodes to 'S...'

	//VersionByteMuxedAccounts is the version byte used for encoded stellar multiplexed addresses
	VersionByteMuxedAccount = 12 << 3 // Base32-encodes to 'M...'

	//VersionByteHashTx is the version byte used for encoded stellar hashTx
	//signer keys.
	VersionByteHashTx = 19 << 3 // Base32-encodes to 'T...'

	//VersionByteHashX is the version byte used for encoded stellar hashX
	//signer keys.
	VersionByteHashX = 23 << 3 // Base32-encodes to 'X...'
)

Variables

View Source
var (
	StellarChainBase string
	StellarChainId   crypto.Hash
)
View Source
var ErrInvalidChecksum = errors.New("invalid checksum")

ErrInvalidChecksum is returned when Validate determines either the checksum or the payload has been corrupted

View Source
var ErrInvalidVersionByte = errors.New("invalid version byte")

ErrInvalidVersionByte is returned when the version byte from a provided strkey-encoded string is not one of the valid values.

Functions

func Checksum added in v0.13.6

func Checksum(data []byte) []byte

Checksum returns the 2-byte checksum for the provided data

func Decode added in v0.13.6

func Decode(expected VersionByte, src string) ([]byte, error)

Decode decodes the provided StrKey into a raw value, checking the checksum and ensuring the expected VersionByte (the version parameter) is the value actually encoded into the provided src string.

func Encode added in v0.13.6

func Encode(version VersionByte, src []byte) (string, error)

Encode encodes the provided data to a StrKey, using the provided version byte.

func GenerateAssetId

func GenerateAssetId(assetKey string) crypto.Hash

func IsValidEd25519PublicKey added in v0.13.6

func IsValidEd25519PublicKey(i any) bool

IsValidEd25519PublicKey validates a stellar public key

func IsValidEd25519SecretSeed added in v0.13.6

func IsValidEd25519SecretSeed(i any) bool

IsValidEd25519SecretSeed validates a stellar secret key

func MustDecode added in v0.13.6

func MustDecode(expected VersionByte, src string) []byte

MustDecode is like Decode, but panics on error

func MustEncode added in v0.13.6

func MustEncode(version VersionByte, src []byte) string

MustEncode is like Encode, but panics on error

func Validate added in v0.13.6

func Validate(data []byte, expected []byte) error

Validate returns an error if the provided checksum does not match the calculated checksum of the provided data

func VerifyAddress

func VerifyAddress(address string) error

func VerifyAssetKey

func VerifyAssetKey(assetKey string) error

func VerifyTransactionHash

func VerifyTransactionHash(hash string) error

Types

type VersionByte added in v0.13.6

type VersionByte byte

VersionByte represents one of the possible prefix values for a StrKey base string--the string the when encoded using base32 yields a final StrKey.

func DecodeAny added in v0.13.6

func DecodeAny(src string) (VersionByte, []byte, error)

DecodeAny decodes the provided StrKey into a raw value, checking the checksum and if the version byte is one of allowed values.

func Version added in v0.13.6

func Version(src string) (VersionByte, error)

Version extracts and returns the version byte from the provided source string.

Jump to

Keyboard shortcuts

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