package
0.18.4-beta.rc2
Repository: https://github.com/lightningnetwork/lnd.git
Documentation: pkg.go.dev
# README
chainntnfs
The chainntnfs package implements a set of interfaces which allow callers to receive notifications in response to specific on-chain events. The set of notifications available include:
- Notifications for each new block connected to the current best chain.
- Notifications once a
txid
has reached a specified number of confirmations. - Notifications once a target outpoint (
txid:index
) has been spent.
These notifications are used within lnd
in order to properly handle the
workflows for: channel funding, cooperative channel closures, forced channel
closures, channel contract breaches, sweeping time-locked outputs, and finally
pruning the channel graph.
This package is intentionally general enough to be applicable outside the
specific use cases within lnd
outlined above. The current sole concrete
implementation of the ChainNotifier
interface depends on btcd
.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/chainntnfs
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
ConfDetailsFromTxIndex looks up whether a transaction is already included in a block in the active chain by using the backend node's transaction index.
DisableLog disables all library log output.
GetClientMissedBlocks uses a client's best block to determine what blocks it missed being notified about, and returns them in a slice.
GetCommonBlockAncestorHeight takes in: (1) the hash of a block that has been reorged out of the main chain (2) the hash of the block of the same height from the main chain It returns the height of the nearest common ancestor between the two hashes, or an error.
HandleMissedBlocks is called when the chain backend for a notifier misses a series of blocks, handling a reorg if necessary.
NewBestBlockTracker creates a new BestBlockTracker that isn't running yet.
NewConfirmationEvent constructs a new ConfirmationEvent with newly opened channels.
NewConfRequest creates a request for a confirmation notification of either a txid or output script.
NewMempoolNotifier takes a chain connection and returns a new mempool notifier.
NewMockMempoolWatcher returns a new instance of a mock mempool watcher.
NewSpendEvent constructs a new SpendEvent with newly opened channels.
NewSpendRequest creates a request for a spend notification of either an outpoint or output script.
NewTxNotifier creates a TxNotifier.
RegisteredNotifiers returns a slice of all currently registered notifiers.
RegisterNotifier registers a NotifierDriver which is capable of driving a concrete ChainNotifier interface.
RewindChain handles internal state updates for the notifier's TxNotifier.
SupportedNotifiers returns a slice of strings that represent the database drivers that have been registered and are therefore supported.
UseLogger uses a specified Logger to output package logging info.
WithIncludeBlock is an optional argument that allows the calelr to specify that the block that mined a transaction should be included in the response.
# Constants
MaxNumConfs is the maximum number of confirmations that can be requested on a transaction.
ReorgSafetyLimit is the chain depth beyond which it is assumed a block will not be reorganized out of the chain.
TxFoundIndex denotes that the transaction was found within the backend node's txindex.
TxFoundManually denotes that the transaction was found within the chain by scanning for it manually.
TxFoundMempool denotes that the transaction was found within the backend node's mempool.
TxNotFoundIndex denotes that the transaction was not found within the backend node's txindex.
TxNotFoundManually denotes that the transaction was not found within the chain by scanning for it manually.
# Variables
ErrChainNotifierShuttingDown is used when we are trying to measure a spend notification when notifier is already stopped.
ErrConfirmHintNotFound is an error returned when a confirm hint for a transaction was not found.
ErrCorruptedHeightHintCache indicates that the on-disk representation has altered since the height hint cache instance was initialized.
ErrEmptyWitnessStack is returned when a spending transaction has an empty witness stack.
ErrNoHeightHint is an error returned when a confirmation/spend registration is attempted without providing an accompanying height hint.
ErrNoScript is an error returned when a confirmation/spend registration is attempted without providing an accompanying output script.
ErrNumConfsOutOfRange is an error returned when a confirmation/spend registration is attempted and the number of confirmations provided is out of range.
ErrSpendHintNotFound is an error returned when a spend hint for an outpoint was not found.
ErrTxNotifierExiting is an error returned when attempting to interact with the TxNotifier but it been shut down.
Log is a logger that is initialized with no output filters.
ZeroHash is the value that should be used as the txid when registering for the confirmation of a script on-chain.
ZeroOutPoint is the value that should be used as the outpoint when registering for the spend of a script on-chain.
ZeroTaprootPkScript is the parsed txscript.PkScript of an empty Taproot SegWit v1 key being pushed to the stack.
# Structs
BestBlockTracker is a tiny subsystem that tracks the blockchain tip and saves the most recent tip information in memory for querying.
BlockEpoch represents metadata concerning each new block connected to the main chain.
BlockEpochEvent encapsulates an on-going stream of block epoch notifications.
ConfirmationEvent encapsulates a confirmation notification.
ConfNtfn represents a notifier client's request to receive a notification once the target transaction/output script gets sufficient confirmations.
ConfRegistration encompasses all of the information required for callers to retrieve details about a confirmation event.
ConfRequest encapsulates a request for a confirmation notification of either a txid or output script.
HistoricalConfDispatch parametrizes a manual rescan for a particular transaction/output script.
HistoricalSpendDispatch parametrizes a manual rescan to determine the spending details (if any) of an outpoint/output script.
MempoolNotifier defines an internal mempool notifier that's used to notify the spending of given inputs.
MempoolSpendEvent is returned to the subscriber to watch for the spending event for the requested input.
MockNotifier is a mock implementation of the ChainNotifier interface.
MockMempoolWatcher is a mock implementation of the MempoolWatcher interface.
NotifierDriver represents a "driver" for a particular interface.
SpendDetail contains details pertaining to a spent output.
SpendEvent encapsulates a spentness notification.
SpendNtfn represents a client's request to receive a notification once an outpoint/output script has been spent on-chain.
SpendRegistration encompasses all of the information required for callers to retrieve details about a spend event.
SpendRequest encapsulates a request for a spend notification of either an outpoint or output script.
TxConfirmation carries some additional block-level details of the exact block that specified transactions was confirmed within.
TxNotifier is a struct responsible for delivering transaction notifications to subscribers.
# Interfaces
BestBlockView is an interface that allows the querying of the most up-to-date blockchain state with low overhead.
ChainConn enables notifiers to pass in their chain backend to interface functions that require it.
ChainNotifier represents a trusted source to receive notifications concerning targeted events on the Bitcoin blockchain.
ConfirmHintCache is an interface whose duty is to cache confirm hints for transactions.
MempoolWatcher defines an interface that allows the caller to query information in the mempool.
SpendHintCache is an interface whose duty is to cache spend hints for outpoints.
TxIndexConn abstracts an RPC backend with txindex enabled.
# Type aliases
NotifierOption is a functional option that allows a caller to modify the events received from the notifier.
TxConfStatus denotes the status of a transaction's lookup.