Documentation
¶
Overview ¶
Package monitor provides Bitcoin transaction monitoring functionality. It watches for new transactions via ZMQ and tracks transactions related to specified addresses.
Index ¶
- type AddressAPI
- type BitcoinLogger
- func (l *BitcoinLogger) Debugf(format string, args ...interface{})
- func (l *BitcoinLogger) Errorf(format string, args ...interface{})
- func (l *BitcoinLogger) Fatalf(format string, args ...interface{})
- func (l *BitcoinLogger) Infof(format string, args ...interface{})
- func (l *BitcoinLogger) Warnf(format string, args ...interface{})
- type ElectrumClient
- type TxMonitor
- type TxNotification
- type UtxoMonitor
- type UtxoResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressAPI ¶
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 ¶
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