monitor

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package monitor provides Bitcoin transaction monitoring functionality. It watches for new transactions via ZMQ and tracks transactions related to specified addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressAPI

type AddressAPI interface {
	GetAddresses() []api.Address
}

AddressAPI defines the interface for retrieving watched addresses.

type BitcoinLogger

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

BitcoinLogger wraps zerolog.Logger to provide Bitcoin-specific logging functionality.

func (*BitcoinLogger) Debugf

func (l *BitcoinLogger) Debugf(format string, args ...interface{})

func (*BitcoinLogger) Errorf

func (l *BitcoinLogger) Errorf(format string, args ...interface{})

func (*BitcoinLogger) Fatalf

func (l *BitcoinLogger) Fatalf(format string, args ...interface{})

func (*BitcoinLogger) Infof

func (l *BitcoinLogger) Infof(format string, args ...interface{})

func (*BitcoinLogger) Warnf

func (l *BitcoinLogger) Warnf(format string, args ...interface{})

type ElectrumClient

type ElectrumClient interface {
	ListUnspent(ctx context.Context, scripthash string) ([]*electrum.ListUnspentResult, error)
	GetHistory(ctx context.Context, scripthash string) ([]*electrum.GetMempoolResult, error)
	GetTransaction(ctx context.Context, txHash string) (*electrum.GetTransactionResult, error)
}

type TxMonitor

type TxMonitor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TxMonitor handles the monitoring of Bitcoin transactions. It maintains a list of subscribers that receive transaction notifications.

func InitTxMonitor

func InitTxMonitor(host string, port int, addressApi AddressAPI, electrumClient ElectrumClient) (*TxMonitor, error)

InitTxMonitor creates and initializes a new TxMonitor instance. It sets up ZMQ subscription for raw transactions and starts the monitoring process.

func (*TxMonitor) Subscribe

func (m *TxMonitor) Subscribe() <-chan TxNotification

Subscribe creates and returns a new channel for receiving transaction notifications. The channel will receive notifications for all transactions matching watched addresses.

type TxNotification

type TxNotification struct {
	MatchedAddress []api.Address // Addresses that matched this transaction
	Tx             wire.MsgTx    // The actual transaction
	Sent           bool          // Whether funds were sent from a watched address
	Confirmed      bool          // Whether the transaction is confirmed
	Amount         int           // Transaction amount in satoshis
}

TxNotification represents a notification about a relevant Bitcoin transaction.

type UtxoMonitor

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

func InitUtxoMonitor

func InitUtxoMonitor(electrumClient ElectrumClient) UtxoMonitor

func (UtxoMonitor) EnqueueScan

func (um UtxoMonitor) EnqueueScan(scriptHash string)

func (UtxoMonitor) GetUtxoStream

func (um UtxoMonitor) GetUtxoStream() <-chan interface{}

type UtxoResult

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

func (UtxoResult) GetScriptHash

func (ur UtxoResult) GetScriptHash() string

func (UtxoResult) GetUtxoData

func (ur UtxoResult) GetUtxoData() []*electrum.ListUnspentResult

Jump to

Keyboard shortcuts

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