Documentation ¶
Index ¶
- Constants
- Variables
- func Cat(x, y data) data
- func CheckEncodeCashAddress(input []byte, prefix string, t AddressType) string
- func CreateChecksum(prefix string, payload data) data
- func DecodeAddress(addr string, defaultNet *chaincfg.Params) (btcutil.Address, error)
- func DecodeCashAddress(str string) (string, data, error)
- func Encode(prefix string, payload data) string
- func ExpandPrefix(prefix string) data
- func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (btcutil.Address, error)
- func LowerCase(c byte) byte
- func PolyMod(v data) uint64
- func VerifyChecksum(prefix string, payload data) bool
- type AddressType
- type CashAddressPubKeyHash
- type CashAddressScriptHash
Constants ¶
const CHARSET string = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
*
- The cashaddr character set for encoding.
Variables ¶
var ( // ErrChecksumMismatch describes an error where decoding failed due // to a bad checksum. ErrChecksumMismatch = errors.New("checksum mismatch") // ErrUnknownAddressType describes an error where an address can not // decoded as a specific address type due to the string encoding // begining with an identifier byte unknown to any standard or // registered (via chaincfg.Register) network. ErrUnknownAddressType = errors.New("unknown address type") // ErrAddressCollision describes an error where an address can not // be uniquely determined as either a pay-to-pubkey-hash or // pay-to-script-hash address since the leading identifier is used for // describing both address kinds, but for different networks. Rather // than assuming or defaulting to one or the other, this error is // returned and the caller must decide how to decode the address. ErrAddressCollision = errors.New("address collision") // ErrInvalidFormat describes an error where decoding failed due to invalid version ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing") Prefixes map[string]string )
var CHARSET_REV = [128]int8{}/* 128 elements not displayed */
*
- The cashaddr character set for decoding.
Functions ¶
func CheckEncodeCashAddress ¶
func CheckEncodeCashAddress(input []byte, prefix string, t AddressType) string
func DecodeAddress ¶
DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.
The bitcoin cash network the address is associated with is extracted if possible.
func ExpandPrefix ¶
func ExpandPrefix(prefix string) data
*
- Expand the address prefix for the checksum computation.
func ExtractPkScriptAddrs ¶
ExtractPkScriptAddrs returns the type of script, addresses and required signatures associated with the passed PkScript. Note that it only works for 'standard' transaction script types. Any data such as public keys which are invalid are omitted from the results.
Types ¶
type AddressType ¶
type AddressType int
const ( P2PKH AddressType = 0 P2SH AddressType = 1 )
func CheckDecodeCashAddress ¶
func CheckDecodeCashAddress(input string) (result []byte, prefix string, t AddressType, err error)
CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
type CashAddressPubKeyHash ¶
type CashAddressPubKeyHash struct {
// contains filtered or unexported fields
}
AddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH) transaction.
func NewCashAddressPubKeyHash ¶
func NewCashAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*CashAddressPubKeyHash, error)
NewAddressPubKeyHash returns a new AddressPubKeyHash. pkHash mustbe 20 bytes.
func (*CashAddressPubKeyHash) EncodeAddress ¶
func (a *CashAddressPubKeyHash) EncodeAddress() string
EncodeAddress returns the string encoding of a pay-to-pubkey-hash address. Part of the Address interface.
func (*CashAddressPubKeyHash) Hash160 ¶
func (a *CashAddressPubKeyHash) Hash160() *[ripemd160.Size]byte
Hash160 returns the underlying array of the pubkey hash. This can be useful when an array is more appropiate than a slice (for example, when used as map keys).
func (*CashAddressPubKeyHash) IsForNet ¶
func (a *CashAddressPubKeyHash) IsForNet(net *chaincfg.Params) bool
IsForNet returns whether or not the pay-to-pubkey-hash address is associated with the passed bitcoin cash network.
func (*CashAddressPubKeyHash) ScriptAddress ¶
func (a *CashAddressPubKeyHash) ScriptAddress() []byte
ScriptAddress returns the bytes to be included in a txout script to pay to a pubkey hash. Part of the Address interface.
func (*CashAddressPubKeyHash) String ¶
func (a *CashAddressPubKeyHash) String() string
String returns a human-readable string for the pay-to-pubkey-hash address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.
type CashAddressScriptHash ¶
type CashAddressScriptHash struct {
// contains filtered or unexported fields
}
AddressScriptHash is an Address for a pay-to-script-hash (P2SH) transaction.
func NewCashAddressScriptHash ¶
func NewCashAddressScriptHash(serializedScript []byte, net *chaincfg.Params) (*CashAddressScriptHash, error)
NewAddressScriptHash returns a new AddressScriptHash.
func NewCashAddressScriptHashFromHash ¶
func NewCashAddressScriptHashFromHash(scriptHash []byte, net *chaincfg.Params) (*CashAddressScriptHash, error)
NewAddressScriptHashFromHash returns a new AddressScriptHash. scriptHash must be 20 bytes.
func (*CashAddressScriptHash) EncodeAddress ¶
func (a *CashAddressScriptHash) EncodeAddress() string
EncodeAddress returns the string encoding of a pay-to-script-hash address. Part of the Address interface.
func (*CashAddressScriptHash) Hash160 ¶
func (a *CashAddressScriptHash) Hash160() *[ripemd160.Size]byte
Hash160 returns the underlying array of the script hash. This can be useful when an array is more appropiate than a slice (for example, when used as map keys).
func (*CashAddressScriptHash) IsForNet ¶
func (a *CashAddressScriptHash) IsForNet(net *chaincfg.Params) bool
IsForNet returns whether or not the pay-to-script-hash address is associated with the passed bitcoin cash network.
func (*CashAddressScriptHash) ScriptAddress ¶
func (a *CashAddressScriptHash) ScriptAddress() []byte
ScriptAddress returns the bytes to be included in a txout script to pay to a script hash. Part of the Address interface.
func (*CashAddressScriptHash) String ¶
func (a *CashAddressScriptHash) String() string
String returns a human-readable string for the pay-to-script-hash address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.