Documentation
¶
Overview ¶
Huge thanks to the btcsuite developers for creating this code, which we adapted for our use in compliance with the Copyfree Initiative. btcsuite base58 repo: https://github.com/btcsuite/btcd/tree/master/btcutil/base58
AUTOGENERATED by gen_alphabet.go; do not edit.
Index ¶
- Constants
- Variables
- func Base58CheckDecode(input string) (result []byte, err error)
- func Base58CheckEncode(input []byte, prefix ...byte) string
- func ClassicAddressToXAddress(address string, tag uint32, tagFlag, testnetFlag bool) (string, error)
- func Decode(b58string string, typePrefix []byte) ([]byte, error)
- func DecodeAccountPublicKey(key string) ([]byte, error)
- func DecodeBase58(b string) []byte
- func DecodeClassicAddressToAccountID(cAddress string) (typePrefix, accountID []byte, err error)
- func DecodeNodePublicKey(key string) ([]byte, error)
- func DecodeSeed(seed string) ([]byte, interfaces.CryptoImplementation, error)
- func DecodeXAddress(xAddress string) (accountID []byte, tag uint32, testnet bool, err error)
- func Encode(b []byte, typePrefix []byte, expectedLength int) (string, error)
- func EncodeAccountIDToClassicAddress(accountID []byte) (string, error)
- func EncodeAccountPublicKey(b []byte) (string, error)
- func EncodeBase58(b []byte) string
- func EncodeClassicAddressFromPublicKeyHex(pubkeyhex string) (string, error)
- func EncodeNodePublicKey(b []byte) (string, error)
- func EncodeSeed(entropy []byte, encodingType interfaces.CryptoImplementation) (string, error)
- func EncodeXAddress(accountID []byte, tag uint32, tagFlag, testnetFlag bool) (string, error)
- func IsValidAddress(address string) bool
- func IsValidClassicAddress(cAddress string) bool
- func IsValidXAddress(xAddress string) bool
- func Sha256RipeMD160(b []byte) []byte
- func XAddressToClassicAddress(xAddress string) (classicAddress string, tag uint32, testnet bool, err error)
- type EncodeLengthError
Constants ¶
const ( // Lengths in bytes AccountAddressLength = 20 AccountPublicKeyLength = 33 FamilySeedLength = 16 NodePublicKeyLength = 33 // Account/classic address prefix - value is 0 AccountAddressPrefix = 0x00 // Account public key prefix - value is 35 AccountPublicKeyPrefix = 0x23 // Family seed prefix - value is 33 FamilySeedPrefix = 0x21 // Node/validation public key prefix - value is 28 NodePublicKeyPrefix = 0x1C )
Variables ¶
var ( // Invalid classic address ErrInvalidClassicAddress = errors.New("invalid classic address") // Invalid seed ErrInvalidSeed = errors.New("invalid seed; could not determine encoding algorithm") // Invalid x-address ErrInvalidXAddress = errors.New("invalid x-address") // Invalid tag ErrInvalidTag = errors.New("invalid tag") // Invalid accountId ErrInvalidAccountID = errors.New("invalid accountId") // Invalid xrpl address, general error ErrInvalidAddressFormat = errors.New("invalid address format") // ErrChecksum indicates that the checksum of a check-encoded string does not verify against // the checksum. ErrChecksum = errors.New("checksum error") // ErrInvalidFormat indicates that the check-encoded string has an invalid format. ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing") )
var ( MainnetXAddressPrefix = []byte{0x05, 0x44} TestnetXAddressPrefix = []byte{0x04, 0x93} // X-address length - value is 35 XAddressLength = 35 )
Functions ¶
func Base58CheckDecode ¶
CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
func Base58CheckEncode ¶
CheckEncode prepends a version byte, appends a four byte checksum and returns a base58 encoding of the byte slice.
func ClassicAddressToXAddress ¶
func ClassicAddressToXAddress(address string, tag uint32, tagFlag, testnetFlag bool) (string, error)
ClassicAddressToXAddress converts the classic address to an x-address. It returns the x-address. If the classic address is invalid, it returns an error.
func DecodeAccountPublicKey ¶
Returns the decoded account public key encoding as a byte slice from a base58 string.
func DecodeBase58 ¶
Decodes a modified base58 string to a byte slice.
func DecodeClassicAddressToAccountID ¶
Returns the decoded 'accountID' byte slice of the classic address.
func DecodeNodePublicKey ¶
Returns the decoded node public key encoding as a byte slice from a base58 string.
func DecodeSeed ¶
func DecodeSeed(seed string) ([]byte, interfaces.CryptoImplementation, error)
Returns decoded seed and its algorithm.
func DecodeXAddress ¶
DecodeXAddress returns the accountId, tag, and testnet boolean decoding of the x-address. If the x-address is invalid, it returns an error.
func Encode ¶
Returns the base58 encoding of byte slice, with the given type prefix, whilst ensuring that the byte slice is the expected length.
func EncodeAccountIDToClassicAddress ¶
EncodeAccountIDToClassicAddress returns the classic address encoding of the accountId.
func EncodeAccountPublicKey ¶
Returns the account public key encoding of the byte slice as a base58 string.
func EncodeBase58 ¶
Encodes a byte slice to a base58 string encoded with the XRP alphabet.
func EncodeClassicAddressFromPublicKeyHex ¶
Returns the classic address from public key hex string.
func EncodeNodePublicKey ¶
Returns the node public key encoding of the byte slice as a base58 string.
func EncodeSeed ¶
func EncodeSeed(entropy []byte, encodingType interfaces.CryptoImplementation) (string, error)
Returns a base58 encoding of a seed.
func EncodeXAddress ¶
EncodeXAddress returns the x-address encoding of the accountId, tag, and testnet boolean. If the accountId is not 20 bytes long, it returns an error.
func IsValidAddress ¶
IsValidAddress returns true if the address is valid. Otherwise, it returns false. Address can only be a classic address or an x-address.
func IsValidClassicAddress ¶
IsValidClassicAddress returns true if the classic address is valid. Otherwise, it returns false.
func IsValidXAddress ¶
IsValidXAddress returns true if the x-address is valid. Otherwise, it returns false.
func Sha256RipeMD160 ¶
Returns byte slice of a double hashed given byte slice. The given byte slice is SHA256 hashed, then the result is RIPEMD160 hashed.
func XAddressToClassicAddress ¶
func XAddressToClassicAddress(xAddress string) (classicAddress string, tag uint32, testnet bool, err error)
XAddressToClassicAddress converts the x-address to a classic address. It returns the classic address, tag and testnet boolean. If the x-address is invalid, it returns an error.
Types ¶
type EncodeLengthError ¶
EncodeLengthError is an error that occurs when the length of the input does not match the expected length.
func (*EncodeLengthError) Error ¶
func (e *EncodeLengthError) Error() string
Error implements the error interface.