address

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CHARSET string = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"

CHARSET is the cashaddr character set for encoding.

View Source
const Radix = len(base58table)

Radix of the base58 encoding system.

Variables

View Source
var BitsPerDigit = math.Log2(float64(Radix))

BitsPerDigit - Bits of entropy per base 58 digit.

Functions

func AddressFromPublicKey

func AddressFromPublicKey(pubKey *btcec.PublicKey, mainnet bool) string

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

func AddressFromPublicKeyHash(pubKeyHash []byte, mainnet bool) string

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

func AddressToPubKeyHash(address string) (publicKeyHash string, err error)

AddressToPubKeyHash decodes a Bitcoin address (P2PKH) into the hash of the public key encoded as a string of hex values.

func Base58Encode

func Base58Encode(input []byte) string

func DecodeString

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

DecodeString returns the bytes represented by the base58 string s

func EncodeToString

func EncodeToString(src []byte) string

EncodeToString returns a string from a byte slice.

func MaxEncodedLen

func MaxEncodedLen(b []byte) int

MaxEncodedLen - returns the maximum possible length of a base58 encoding. This number may be larger than the encoded slice.

func PublicKeyHashFromPublicKey

func PublicKeyHashFromPublicKey(pubKey *btcec.PublicKey) string

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

func PublicKeyHashFromPublicKeyStr(pubKeyStr string) (string, error)

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

func PublicKeyToP2PKHScript(pubkey []byte) []byte

func ValidateWalletAddress

func ValidateWalletAddress(coin string, address string) (bool, error)

ValidateWalletAddress will check that the address is valid for the specified coin.

Types

type Address

type Address struct {
	AddressString string
	PublicKeyHash string
}

An Address contains the address string as well as the public key hash string.

func NewAddressFromPublicKey

func NewAddressFromPublicKey(pubKey string, mainnet bool) (*Address, error)

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

func NewAddressFromPublicKeyHash(hash []byte, mainnet bool) (*Address, error)

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

func NewAddressFromString(addr string) (*Address, error)

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.

Jump to

Keyboard shortcuts

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