encoding

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package encoding provides various encoding utilities for cryptocurrency addresses

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base32StdDecode added in v1.1.0

func Base32StdDecode(s string) ([]byte, error)

Base32StdDecode decodes standard Base32 string (handles missing padding)

func Base32StdEncode added in v1.1.0

func Base32StdEncode(data []byte) string

Base32StdEncode encodes bytes to standard Base32 (no padding) - used by Stellar

func Base58CheckDecode

func Base58CheckDecode(input string) (version byte, payload []byte, err error)

Base58CheckDecode decodes and verifies the checksum

func Base58CheckEncode

func Base58CheckEncode(version byte, payload []byte) string

Base58CheckEncode encodes with a 4-byte checksum (used in Bitcoin addresses)

func Base58Decode

func Base58Decode(input string) ([]byte, error)

Base58Decode decodes a Base58 string to a byte slice

func Base58Encode

func Base58Encode(input []byte) string

Base58Encode encodes a byte slice to a Base58 string

func Bech32Decode added in v1.1.0

func Bech32Decode(bech string) (string, []byte, error)

Bech32Decode decodes a bech32 string into hrp and data

func Bech32Encode added in v1.1.0

func Bech32Encode(hrp string, data []byte) (string, error)

Bech32Encode encodes data with a human-readable part into a bech32 string

func CRC16XMODEM added in v1.1.0

func CRC16XMODEM(data []byte) uint16

CRC16XMODEM computes CRC-16/XMODEM checksum

func ConvertBits added in v1.1.0

func ConvertBits(data []byte, fromBits, toBits int, pad bool) ([]byte, error)

ConvertBits converts data between bit groups (exported version)

func EncodeCashAddr

func EncodeCashAddr(prefix string, addrType CashAddrType, hash []byte) (string, error)

EncodeCashAddr encodes a hash to CashAddr format

func SS58Decode added in v1.1.0

func SS58Decode(address string) (network byte, publicKey []byte, err error)

SS58Decode decodes an SS58 address to network prefix and public key

func SS58Encode added in v1.1.0

func SS58Encode(publicKey []byte, network byte) (string, error)

SS58Encode encodes a public key with a network prefix to SS58 format

Types

type CashAddrType

type CashAddrType byte

CashAddrType represents the type of CashAddr

const (
	CashAddrTypeP2PKH CashAddrType = 0
	CashAddrTypeP2SH  CashAddrType = 1
)

func DecodeCashAddr

func DecodeCashAddr(address string) (prefix string, addrType CashAddrType, hash []byte, err error)

DecodeCashAddr decodes a CashAddr to its components

Jump to

Keyboard shortcuts

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