onchain

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfirmed = errors.New("lockup transaction not confirmed")
View Source
var RegtestElectrumConfig = ElectrumConfig{
	Btc:    ElectrumOptions{Url: "localhost:19001"},
	Liquid: ElectrumOptions{Url: "localhost:19002"},
}

Functions

This section is empty.

Types

type AddressProvider

type AddressProvider interface {
	IsUsed(address string) (bool, error)
}

type Balance

type Balance struct {
	Total       uint64
	Confirmed   uint64
	Unconfirmed uint64
}

type BlockEpoch

type BlockEpoch struct {
	Height uint32
}

type BlockProvider

type BlockProvider interface {
	RegisterBlockListener(ctx context.Context, channel chan<- *BlockEpoch) error
	GetBlockHeight() (uint32, error)
	EstimateFee() (float64, error)
	Disconnect()
	GetUnspentOutputs(address string) ([]*Output, error)
}

type BoltzTxProvider

type BoltzTxProvider struct {
	*boltz.Api
	// contains filtered or unexported fields
}

func (BoltzTxProvider) BroadcastTransaction

func (txProvider BoltzTxProvider) BroadcastTransaction(txHex string) (string, error)

func (BoltzTxProvider) GetRawTransaction

func (txProvider BoltzTxProvider) GetRawTransaction(txId string) (string, error)

func (BoltzTxProvider) IsTransactionConfirmed

func (txProvider BoltzTxProvider) IsTransactionConfirmed(txId string) (bool, error)

type Currency

type Currency struct {
	Blocks BlockProvider
	Tx     TxProvider
	// contains filtered or unexported fields
}

type ElectrumConfig

type ElectrumConfig struct {
	Btc    ElectrumOptions
	Liquid ElectrumOptions
}

type ElectrumOptions

type ElectrumOptions struct {
	Url string
	SSL bool
}

type Id

type Id = uint64

type MultiTxProvider

type MultiTxProvider struct {
	TxProvider
	Providers []TxProvider
}

func (MultiTxProvider) BroadcastTransaction

func (m MultiTxProvider) BroadcastTransaction(txHex string) (txId string, err error)

func (MultiTxProvider) GetRawTransaction

func (m MultiTxProvider) GetRawTransaction(txId string) (hex string, err error)

func (MultiTxProvider) IsTransactionConfirmed

func (m MultiTxProvider) IsTransactionConfirmed(txId string) (confirmed bool, err error)

type Onchain

type Onchain struct {
	Btc            *Currency
	Liquid         *Currency
	Network        *boltz.Network
	Wallets        []Wallet
	OnWalletChange *utils.ChannelForwarder[[]Wallet]
}

func (*Onchain) AddWallet

func (onchain *Onchain) AddWallet(wallet Wallet)

func (*Onchain) BroadcastTransaction

func (onchain *Onchain) BroadcastTransaction(transaction boltz.Transaction) (string, error)

func (*Onchain) Disconnect

func (onchain *Onchain) Disconnect()

func (*Onchain) EstimateFee

func (onchain *Onchain) EstimateFee(currency boltz.Currency, allowLowball bool) (float64, error)

func (*Onchain) FindOutput

func (onchain *Onchain) FindOutput(info OutputArgs) (*OutputResult, error)

func (*Onchain) GetAnyWallet

func (onchain *Onchain) GetAnyWallet(checker WalletChecker) (Wallet, error)

func (*Onchain) GetBlockHeight

func (onchain *Onchain) GetBlockHeight(currency boltz.Currency) (uint32, error)

func (*Onchain) GetBlockProvider

func (onchain *Onchain) GetBlockProvider(currency boltz.Currency) BlockProvider

func (*Onchain) GetCurrency

func (onchain *Onchain) GetCurrency(currency boltz.Currency) (*Currency, error)

func (*Onchain) GetTransaction

func (onchain *Onchain) GetTransaction(currency boltz.Currency, txId string, ourOutputBlindingKey *btcec.PrivateKey) (boltz.Transaction, error)

func (*Onchain) GetTransactionFee

func (onchain *Onchain) GetTransactionFee(currency boltz.Currency, txId string) (uint64, error)

func (*Onchain) GetUnspentOutputs

func (onchain *Onchain) GetUnspentOutputs(currency boltz.Currency, address string) ([]*Output, error)

func (*Onchain) GetWallets

func (onchain *Onchain) GetWallets(checker WalletChecker) []Wallet

func (*Onchain) Init

func (onchain *Onchain) Init()

func (*Onchain) IsTransactionConfirmed

func (onchain *Onchain) IsTransactionConfirmed(currency boltz.Currency, txId string) (bool, error)

func (*Onchain) RegisterBlockListener

func (onchain *Onchain) RegisterBlockListener(ctx context.Context, currency boltz.Currency) *utils.ChannelForwarder[*BlockEpoch]

func (*Onchain) RemoveWallet

func (onchain *Onchain) RemoveWallet(id Id)

type Output

type Output struct {
	TxId  string
	Value uint64
}

type OutputArgs

type OutputArgs struct {
	TransactionId    string
	Currency         boltz.Currency
	Address          string
	BlindingKey      *btcec.PrivateKey
	ExpectedAmount   uint64
	RequireConfirmed bool
}

type OutputResult

type OutputResult struct {
	Transaction boltz.Transaction
	Vout        uint32
	Value       uint64
}

type TransactionOutput

type TransactionOutput struct {
	Address      string
	Amount       uint64
	IsOurAddress bool
}

type TxProvider

type TxProvider interface {
	GetRawTransaction(txId string) (string, error)
	BroadcastTransaction(txHex string) (string, error)
	IsTransactionConfirmed(txId string) (bool, error)
}

func NewBoltzTxProvider

func NewBoltzTxProvider(boltz *boltz.Api, currency boltz.Currency) TxProvider

type Wallet

type Wallet interface {
	NewAddress() (string, error)
	SendToAddress(address string, amount uint64, satPerVbyte float64, sendAll bool) (string, error)
	Ready() bool
	GetBalance() (*Balance, error)
	GetWalletInfo() WalletInfo
	Disconnect() error
	GetTransactions(limit, offset uint64) ([]*WalletTransaction, error)
}

type WalletChecker

type WalletChecker struct {
	Id            *Id
	Name          *string
	Currency      boltz.Currency
	AllowReadonly bool
	TenantId      *Id
}

func (*WalletChecker) Allowed

func (walletChecker *WalletChecker) Allowed(wallet Wallet) bool

type WalletInfo

type WalletInfo struct {
	Id       Id
	Name     string
	Currency boltz.Currency
	Readonly bool
	TenantId Id
}

func (WalletInfo) InsufficientBalanceError

func (info WalletInfo) InsufficientBalanceError(amount uint64) error

type WalletTransaction

type WalletTransaction struct {
	Id              string
	Timestamp       time.Time
	Outputs         []TransactionOutput
	BlockHeight     uint32
	BalanceChange   int64
	IsConsolidation bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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