bitcoindnotify

package
v0.18.0-beta.rc3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitcoindNotifier

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

BitcoindNotifier implements the ChainNotifier interface using a bitcoind chain client. Multiple concurrent clients are supported. All notifications are achieved via non-blocking sends on client channels.

func New

func New(chainConn *chain.BitcoindConn, chainParams *chaincfg.Params,
	spendHintCache chainntnfs.SpendHintCache,
	confirmHintCache chainntnfs.ConfirmHintCache,
	blockCache *blockcache.BlockCache) *BitcoindNotifier

New returns a new BitcoindNotifier instance. This function assumes the bitcoind node detailed in the passed configuration is already running, and willing to accept RPC requests and new zmq clients.

func (*BitcoindNotifier) CancelMempoolSpendEvent

func (b *BitcoindNotifier) CancelMempoolSpendEvent(
	sub *chainntnfs.MempoolSpendEvent)

CancelMempoolSpendEvent allows the caller to cancel a subscription to watch for a spend of an outpoint in the mempool.

NOTE: part of the MempoolWatcher interface.

func (*BitcoindNotifier) GetBlock

func (b *BitcoindNotifier) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock,
	error)

GetBlock is used to retrieve the block with the given hash. This function wraps the blockCache's GetBlock function.

func (*BitcoindNotifier) LookupInputMempoolSpend

func (b *BitcoindNotifier) LookupInputMempoolSpend(
	op wire.OutPoint) fn.Option[wire.MsgTx]

LookupInputMempoolSpend takes an outpoint and queries the mempool to find its spending tx. Returns the tx if found, otherwise fn.None.

NOTE: part of the MempoolWatcher interface.

func (*BitcoindNotifier) RegisterBlockEpochNtfn

func (b *BitcoindNotifier) 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 (*BitcoindNotifier) RegisterConfirmationsNtfn

func (b *BitcoindNotifier) 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 (*BitcoindNotifier) RegisterSpendNtfn

func (b *BitcoindNotifier) 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 (*BitcoindNotifier) Start

func (b *BitcoindNotifier) Start() error

Start connects to the running bitcoind node over websockets, registers for block notifications, and finally launches all related helper goroutines.

func (*BitcoindNotifier) Started

func (b *BitcoindNotifier) Started() bool

Started returns true if this instance has been started, and false otherwise.

func (*BitcoindNotifier) Stop

func (b *BitcoindNotifier) Stop() error

Stop shutsdown the BitcoindNotifier.

func (*BitcoindNotifier) SubscribeMempoolSpent

func (b *BitcoindNotifier) SubscribeMempoolSpent(
	outpoint wire.OutPoint) (*chainntnfs.MempoolSpendEvent, error)

SubscribeMempoolSpent allows the caller to register a subscription to watch for a spend of an outpoint in the mempool.The event will be dispatched once the outpoint is spent in the mempool.

NOTE: part of the MempoolWatcher interface.

Jump to

Keyboard shortcuts

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