watcher

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "WCHR"

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Config

type Config struct {
	// ChainNotifier is responsible for requesting confirmation and spend
	// notifications for accounts.
	ChainNotifier lndclient.ChainNotifierClient

	// HandleAccountConf abstracts the operations that should be performed
	// for an account once we detect its confirmation. The account is
	// identified by its user sub key (i.e., trader key).
	HandleAccountConf func(*btcec.PublicKey, *chainntnfs.TxConfirmation) error

	// HandleAccountSpend abstracts the operations that should be performed
	// for an account once we detect its spend. The account is identified by
	// its user sub key (i.e., trader key).
	HandleAccountSpend func(*btcec.PublicKey, *chainntnfs.SpendDetail) error

	// HandleAccountExpiry the operations that should be perform for an
	// account once it's expired. The account is identified by its user sub
	// key (i.e., trader key).
	HandleAccountExpiry func(*btcec.PublicKey, uint32) error
}

Config contains all of the Watcher's dependencies in order to carry out its duties.

type Watcher

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

Watcher is responsible for the on-chain interaction of an account, whether that is confirmation or spend.

func New

func New(cfg *Config) *Watcher

New instantiates a new chain watcher backed by the given config.

func (*Watcher) CancelAccountConf

func (w *Watcher) CancelAccountConf(traderKey *btcec.PublicKey)

CancelAccountConf cancels the conf watcher of the given account, if one is active.

func (*Watcher) CancelAccountSpend

func (w *Watcher) CancelAccountSpend(traderKey *btcec.PublicKey)

CancelAccountSpend cancels the spend watcher of the given account, if one is active.

func (*Watcher) Start

func (w *Watcher) Start() error

Start allows the Watcher to begin accepting watch requests.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop safely stops any ongoing requests within the Watcher.

func (*Watcher) WatchAccountConf

func (w *Watcher) WatchAccountConf(traderKey *btcec.PublicKey,
	txHash chainhash.Hash, script []byte, numConfs, heightHint uint32) error

WatchAccountConf watches a new account on-chain for its confirmation. Only one conf watcher per account can be used at any time.

NOTE: If there is a previous conf watcher for the given account that has not finished yet, it will be canceled!

func (*Watcher) WatchAccountExpiration

func (w *Watcher) WatchAccountExpiration(traderKey *btcec.PublicKey,
	expiry uint32) error

WatchAccountExpiration watches for the expiration of an account on-chain. Successive calls for the same account will cancel any previous expiration watch requests and the new expiration will be tracked instead.

func (*Watcher) WatchAccountSpend

func (w *Watcher) WatchAccountSpend(traderKey *btcec.PublicKey,
	accountPoint wire.OutPoint, script []byte, heightHint uint32) error

WatchAccountSpend watches for the spend of an account. Only one spend watcher per account can be used at any time.

NOTE: If there is a previous spend watcher for the given account that has not finished yet, it will be canceled!

Jump to

Keyboard shortcuts

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