bch

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssetIdentifier = "bch"
	AssetDecimals   = 1e8
)

Variables

View Source
var (
	ErrInputAlreadyUsed    = errors.New("input already used")
	ErrOutputAlreadyExists = errors.New("output already exists")
)

Functions

func DecodeAddressToCashAddr

func DecodeAddressToCashAddr(address string, params *chaincfg.Params) (string, error)

func DecodeAddressToLegacyAddr

func DecodeAddressToLegacyAddr(address string, params *chaincfg.Params) (string, error)

func IsCashAddrAddress

func IsCashAddrAddress(address string, params *chaincfg.Params) (bool, error)

func IsLegacyAddress

func IsLegacyAddress(address string, params *chaincfg.Params) (bool, error)

func ValidateAddress

func ValidateAddress(addrress string) bool

Types

type BCH

type BCH struct {
	WalletSDK *WalletSDK
	// contains filtered or unexported fields
}

func NewBCH

func NewBCH(conf Config, walletSDK *WalletSDK) (*BCH, error)

func (*BCH) Name

func (t *BCH) Name() string

Name returns the service name

func (*BCH) Node

func (t *BCH) Node() *rpcclient.Client

Node returns the grpc client

func (*BCH) Start

func (t *BCH) Start(_ context.Context) error

Start

func (*BCH) Stop

func (t *BCH) Stop(_ context.Context) error

Stop

type CalculateTxSizeData

type CalculateTxSizeData struct {
	TxFullSize     decimal.Decimal
	TxStrippedSize decimal.Decimal
	Weight         decimal.Decimal
	VSize          decimal.Decimal
	TotalFee       decimal.Decimal
}

type Config

type Config struct {
	RPCConfig *rpcclient.ConnConfig
}

type GenerateAddressData

type GenerateAddressData struct {
	Address       *bchutil.AddressPubKeyHash
	PublicKey     *bchec.PublicKey
	PrivateKey    *bchec.PrivateKey
	PrivateKeyWIF *bchutil.WIF
	MasterKey     *hdkeychain.ExtendedKey
	Sequence      uint32
	// contains filtered or unexported fields
}

func (GenerateAddressData) AddressPubKey

func (s GenerateAddressData) AddressPubKey() (string, error)

type TxBuilder

type TxBuilder struct {
	Inputs []TxInput
	// contains filtered or unexported fields
}

func NewTransactionFromBuilder

func NewTransactionFromBuilder(builder *TxBuilder) *TxBuilder

func NewTxBuilder

func NewTxBuilder(chainParams *chaincfg.Params) *TxBuilder

func (*TxBuilder) AddInput

func (s *TxBuilder) AddInput(input TxInput) error

func (*TxBuilder) AddOutput

func (s *TxBuilder) AddOutput(address string, amount decimal.Decimal) error

func (*TxBuilder) CalculateTxSize

func (s *TxBuilder) CalculateTxSize(feePerByte decimal.Decimal) CalculateTxSizeData

CalculateTxSize calculates the size of the transaction and the fee for it.

Docs: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#transaction-size-calculations

func (*TxBuilder) EmulateTxSize

func (s *TxBuilder) EmulateTxSize(feePerByte decimal.Decimal) (CalculateTxSizeData, error)

EmulateTxSize calculates the size of the transaction and the fee for it.

func (*TxBuilder) MsgTx

func (s *TxBuilder) MsgTx() *wire.MsgTx

MsgTx

func (*TxBuilder) SignTx

func (s *TxBuilder) SignTx() error

SignTx

type TxInput

type TxInput struct {
	PrivateKey *bchec.PrivateKey
	PkScript   string
	Hash       string
	Sequence   uint32
	Amount     int64
}

type WalletSDK

type WalletSDK struct {
	// contains filtered or unexported fields
}

func NewWalletSDK

func NewWalletSDK(chainParams *chaincfg.Params) *WalletSDK

NewWalletSDK creates a new WalletSDK instance.

If chainParams is nil, the mainnet parameters will be used.

func (WalletSDK) AddressFromPrivateKey

func (s WalletSDK) AddressFromPrivateKey(privateKeyWIF string) (string, *bchec.PrivateKey, error)

func (WalletSDK) ChainParams

func (s WalletSDK) ChainParams() *chaincfg.Params

ChainParams returns the chain parameters for the wallet

func (WalletSDK) GenerateAddress

func (s WalletSDK) GenerateAddress(mnemonic, passphrase string, sequenceNumber uint32) (*GenerateAddressData, error)

func (WalletSDK) ValidateAddress

func (s WalletSDK) ValidateAddress(address string) bool

Bitcoin Cash

Jump to

Keyboard shortcuts

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