bitcoin_cash

package
v0.0.0-...-fa9a987 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const SighashForkID = txscript.SigHashType(0x40)
View Source
const SighashMask = txscript.SigHashType(0x1F)

Variables

View Source
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
	}()
)
View Source
var CheckError = bitcoin.CheckError

Functions

func AddressPrefix

func AddressPrefix(params *chaincfg.Params) string

The bch prefix is different for each network type

func AppendBchChecksum

func AppendBchChecksum(prefix string, payload []byte) []byte

Add bch checksum to a payload https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum

func BchAddressFromBytes

func BchAddressFromBytes(addrBytes []byte, params *chaincfg.Params) (btcutil.Address, error)

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

func DecodeBchAddress(addr string, params *chaincfg.Params) ([]byte, error)

DecodeAddress implements the address.Decoder interface

func DecodeBchString

func DecodeBchString(address string) []byte

DecodeString using Bitcoin Cash address encoding.

func EncodeToBchString

func EncodeToBchString(data []byte) string

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

func NewBchAddressPubKey(pk []byte, params *chaincfg.Params) (*btcutil.AddressPubKeyHash, error)

Create a new bch, btc compatible address pkh

func NewClient

func NewClient(cfgI xc.ITask) (client.FullClient, error)

func PolyMod

func PolyMod(v []byte) uint64

PolyMod is the checksum alg for BCH https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md

func VerifyChecksum

func VerifyChecksum(prefix string, payload []byte) bool

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

func (*BchAddressDecoder) Decode

func (*BchAddressDecoder) Decode(inputAddr xc.Address, params *chaincfg.Params) (btcutil.Address, error)

type Tx

type Tx struct {
	*tx.Tx
}

Tx for Bitcoin

func (*Tx) AddSignatures

func (txObj *Tx) AddSignatures(signatures ...xc.TxSignature) error

AddSignatures adds a signature to Tx

func (*Tx) Serialize

func (tx *Tx) Serialize() ([]byte, error)

func (*Tx) Sighashes

func (txObj *Tx) Sighashes() ([]xc.TxDataToSign, error)

Sighashes returns the tx payload to sign, aka sighash

type TxBuilder

type TxBuilder struct {
	bitcoin.TxBuilder
}

TxBuilder for Bitcoin

func NewTxBuilder

func NewTxBuilder(cfgI xc.ITask) (TxBuilder, error)

NewTxBuilder creates a new Bitcoin TxBuilder

func (TxBuilder) NewNativeTransfer

func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

func (TxBuilder) NewTokenTransfer

func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

func (TxBuilder) NewTransfer

func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

func (TxBuilder) Transfer

func (txBuilder TxBuilder) Transfer(args xcbuilder.TransferArgs, input xc.TxInput) (xc.Tx, error)

Jump to

Keyboard shortcuts

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