Documentation ¶
Index ¶
- Constants
- Variables
- func AddressPrefix(params *chaincfg.Params) string
- func AppendBchChecksum(prefix string, payload []byte) []byte
- func BchAddressFromBytes(addrBytes []byte, params *chaincfg.Params) (btcutil.Address, error)
- func CalculateBchBip143Sighash(subScript []byte, sigHashes *txscript.TxSigHashes, ...) []byte
- func DecodeBchAddress(addr string, params *chaincfg.Params) ([]byte, error)
- func DecodeBchString(address string) []byte
- func EncodePrefix(prefixString string) []byte
- func EncodeToBchString(data []byte) string
- func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)
- func NewBchAddressPubKey(pk []byte, params *chaincfg.Params) (*btcutil.AddressPubKeyHash, error)
- func NewClient(cfgI xc.ITask) (client.FullClient, error)
- func PolyMod(v []byte) uint64
- func VerifyChecksum(prefix string, payload []byte) bool
- type AddressBuilder
- func (ab AddressBuilder) GetAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)
- func (ab AddressBuilder) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]xc.PossibleAddress, error)
- func (ab AddressBuilder) GetLegacyAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)
- type BchAddressDecoder
- type Tx
- type TxBuilder
- func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) Transfer(args xcbuilder.TransferArgs, input xc.TxInput) (xc.Tx, error)
Constants ¶
const SighashForkID = txscript.SigHashType(0x40)
const SighashMask = txscript.SigHashType(0x1F)
Variables ¶
var ( // Alphabet used by Bitcoin Cash to encode addresses. Alphabet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" // AlphabetReverseLookup used by Bitcoin Cash to decode addresses. AlphabetReverseLookup = func() map[rune]byte { lookup := map[rune]byte{} for i, char := range Alphabet { lookup[char] = byte(i) } return lookup }() )
var CheckError = bitcoin.CheckError
Functions ¶
func AddressPrefix ¶
The bch prefix is different for each network type
func AppendBchChecksum ¶
Add bch checksum to a payload https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum
func BchAddressFromBytes ¶
func CalculateBchBip143Sighash ¶
func CalculateBchBip143Sighash(subScript []byte, sigHashes *txscript.TxSigHashes, hashType txscript.SigHashType, tx *wire.MsgTx, idx int, amt int64) []byte
https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
func DecodeBchAddress ¶
DecodeAddress implements the address.Decoder interface
func DecodeBchString ¶
DecodeString using Bitcoin Cash address encoding.
func EncodePrefix ¶
https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum
func EncodeToBchString ¶
White bch data as a bch encoded string
func NewAddressBuilder ¶
func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)
NewAddressBuilder creates a new Bitcoin AddressBuilder
func NewBchAddressPubKey ¶
Create a new bch, btc compatible address pkh
func PolyMod ¶
PolyMod is the checksum alg for BCH https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md
func VerifyChecksum ¶
Verify if a bch payload is well formed
Types ¶
type AddressBuilder ¶
type AddressBuilder struct {
// contains filtered or unexported fields
}
AddressBuilder for Bitcoin
func (AddressBuilder) GetAddressFromPublicKey ¶
func (ab AddressBuilder) GetAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)
GetAddressFromPublicKey returns an Address given a public key
func (AddressBuilder) GetAllPossibleAddressesFromPublicKey ¶
func (ab AddressBuilder) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]xc.PossibleAddress, error)
GetAllPossibleAddressesFromPublicKey returns all PossubleAddress(es) given a public key
func (AddressBuilder) GetLegacyAddressFromPublicKey ¶
func (ab AddressBuilder) GetLegacyAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)
type BchAddressDecoder ¶
type BchAddressDecoder struct{}
func NewAddressDecoder ¶
func NewAddressDecoder() *BchAddressDecoder
type Tx ¶
Tx for Bitcoin
func (*Tx) AddSignatures ¶
func (txObj *Tx) AddSignatures(signatures ...xc.TxSignature) error
AddSignatures adds a signature to Tx
type TxBuilder ¶
TxBuilder for Bitcoin
func NewTxBuilder ¶
NewTxBuilder creates a new Bitcoin TxBuilder