Documentation ¶
Index ¶
- type NeutrinoChainConn
- func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
- func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error)
- func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockHeaderVerboseResult, error)
- type NeutrinoNotifier
- func (n *NeutrinoNotifier) GetBlock(hash chainhash.Hash) (*btcutil.Block, error)
- func (n *NeutrinoNotifier) RegisterBlockEpochNtfn(bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)
- func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32, ...) (*chainntnfs.ConfirmationEvent, error)
- func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
- func (n *NeutrinoNotifier) Start() error
- func (n *NeutrinoNotifier) Started() bool
- func (n *NeutrinoNotifier) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NeutrinoChainConn ¶
type NeutrinoChainConn struct {
// contains filtered or unexported fields
}
NeutrinoChainConn is a wrapper around neutrino's chain backend in order to satisfy the chainntnfs.ChainConn interface.
func (*NeutrinoChainConn) GetBlockHash ¶
func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error)
GetBlockHash returns the hash from a block height.
func (*NeutrinoChainConn) GetBlockHeader ¶
func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error)
GetBlockHeader returns the block header for a hash.
func (*NeutrinoChainConn) GetBlockHeaderVerbose ¶
func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) ( *btcjson.GetBlockHeaderVerboseResult, error)
GetBlockHeaderVerbose returns a verbose block header result for a hash. This result only contains the height with a nil hash.
type NeutrinoNotifier ¶
type NeutrinoNotifier struct {
// contains filtered or unexported fields
}
NeutrinoNotifier is a version of ChainNotifier that's backed by the neutrino Bitcoin light client. Unlike other implementations, this implementation speaks directly to the p2p network. As a result, this implementation of the ChainNotifier interface is much more light weight that other implementation which rely of receiving notification over an RPC interface backed by a running full node.
TODO(roasbeef): heavily consolidate with NeutrinoNotifier code
- maybe combine into single package?
func New ¶
func New(node *neutrino.ChainService, spendHintCache chainntnfs.SpendHintCache, confirmHintCache chainntnfs.ConfirmHintCache, blockCache *blockcache.BlockCache) *NeutrinoNotifier
New creates a new instance of the NeutrinoNotifier concrete implementation of the ChainNotifier interface.
NOTE: The passed neutrino node should already be running and active before being passed into this function.
func (*NeutrinoNotifier) GetBlock ¶
GetBlock is used to retrieve the block with the given hash. Since the block cache used by neutrino will be the same as that used by LND (since it is passed to neutrino on initialisation), the neutrino GetBlock method can be called directly since it already uses the block cache. However, neutrino does not lock the block cache mutex for the given block hash and so that is done here.
func (*NeutrinoNotifier) RegisterBlockEpochNtfn ¶
func (n *NeutrinoNotifier) RegisterBlockEpochNtfn( bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)
RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the caller to receive notifications, of each new block connected to the main chain. Clients have the option of passing in their best known block, which the notifier uses to check if they are behind on blocks and catch them up. If they do not provide one, then a notification will be dispatched immediately for the current tip of the chain upon a successful registration.
func (*NeutrinoNotifier) RegisterConfirmationsNtfn ¶
func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32, opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error)
RegisterConfirmationsNtfn registers an intent to be notified once the target txid/output script has reached numConfs confirmations on-chain. When intending to be notified of the confirmation of an output script, a nil txid must be used. The heightHint should represent the earliest height at which the txid/output script could have been included in the chain.
Progress on the number of confirmations left can be read from the 'Updates' channel. Once it has reached all of its confirmations, a notification will be sent across the 'Confirmed' channel.
func (*NeutrinoNotifier) RegisterSpendNtfn ¶
func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
RegisterSpendNtfn registers an intent to be notified once the target outpoint/output script has been spent by a transaction on-chain. When intending to be notified of the spend of an output script, a nil outpoint must be used. The heightHint should represent the earliest height in the chain of the transaction that spent the outpoint/output script.
Once a spend of has been detected, the details of the spending event will be sent across the 'Spend' channel.
func (*NeutrinoNotifier) Start ¶
func (n *NeutrinoNotifier) Start() error
Start contacts the running neutrino light client and kicks off an initial empty rescan.
func (*NeutrinoNotifier) Started ¶
func (n *NeutrinoNotifier) Started() bool
Started returns true if this instance has been started, and false otherwise.
func (*NeutrinoNotifier) Stop ¶
func (n *NeutrinoNotifier) Stop() error
Stop shuts down the NeutrinoNotifier.