Documentation ¶
Index ¶
- Constants
- Variables
- func AddressFromPublicKey(pubKey *btcec.PublicKey, mainnet bool) string
- func AddressFromPublicKeyHash(pubKeyHash []byte, mainnet bool) string
- func AddressToPubKeyHash(address string) (publicKeyHash string, err error)
- func Base58Encode(input []byte) string
- func DecodeString(s string) ([]byte, error)
- func EncodeToString(src []byte) string
- func MaxEncodedLen(b []byte) int
- func PublicKeyHashFromPublicKey(pubKey *btcec.PublicKey) string
- func PublicKeyHashFromPublicKeyStr(pubKeyStr string) (string, error)
- func PublicKeyToP2PKHScript(pubkey []byte) []byte
- func ValidateWalletAddress(coin string, address string) (bool, error)
- type Address
Constants ¶
const CHARSET string = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
CHARSET is the cashaddr character set for encoding.
const Radix = len(base58table)
Radix of the base58 encoding system.
Variables ¶
var BitsPerDigit = math.Log2(float64(Radix))
BitsPerDigit - Bits of entropy per base 58 digit.
Functions ¶
func AddressFromPublicKey ¶
AddressFromPublicKey takes a btcec public key and returns a P2PKH address string. If mainnet parameter is true it will return a mainnet address (starting with a 1). Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
func AddressFromPublicKeyHash ¶
AddressFromPublicKeyHash takes a byte array hash of a public key and returns a P2PKH address string. If mainnet parameter is true it will return a mainnet address (starting with a 1). Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
func AddressToPubKeyHash ¶
AddressToPubKeyHash decodes a Bitcoin address (P2PKH) into the hash of the public key encoded as a string of hex values.
func Base58Encode ¶
func DecodeString ¶
DecodeString returns the bytes represented by the base58 string s
func EncodeToString ¶
EncodeToString returns a string from a byte slice.
func MaxEncodedLen ¶
MaxEncodedLen - returns the maximum possible length of a base58 encoding. This number may be larger than the encoded slice.
func PublicKeyHashFromPublicKey ¶
PublicKeyHashFromPublicKey hashes a btcec public key (in compressed format starting with 03 or 02) and returns the hash encoded as a string of hex values.
func PublicKeyHashFromPublicKeyStr ¶
PublicKeyHashFromPublicKeyStr hashes a public key string (in compressed format starting with 03 or 02) and returns the hash encoded as a string of hex values.
func PublicKeyToP2PKHScript ¶
Types ¶
type Address ¶
An Address contains the address string as well as the public key hash string.
func NewAddressFromPublicKey ¶
NewAddressFromPublicKey takes a public key string and returns an Address struct pointer. If mainnet parameter is true it will return a mainnet address (starting with a 1). Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
func NewAddressFromPublicKeyHash ¶
NewAddressFromPublicKeyHash takes a public key hash in bytes and returns an Address struct pointer. If mainnet parameter is true it will return a mainnet address (starting with a 1). Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
func NewAddressFromString ¶
NewAddressFromString takes a string address (P2PKH) and returns a pointer to an Address which contains the address string as well as the public key hash string.