scanner

package
v0.1.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType int
const (
	UnspentUtxo EventType = iota
)

type OutpointWatchItem

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

OutpointWatchItem can be used to check if an outpoint is spent by transaction inputs

func NewOutpointWatchItemFromInput

func NewOutpointWatchItemFromInput(input *transaction.TxInput, prevoutScript []byte) (*OutpointWatchItem, error)

func (*OutpointWatchItem) Bytes

func (i *OutpointWatchItem) Bytes() []byte

func (*OutpointWatchItem) Match

type Report

type Report struct {
	// Transaction is the transaction that includes the item that was found.
	Transaction *transaction.Transaction

	// BlockHash is the block hash of the block that includes the transaction.
	BlockHash   *chainhash.Hash
	BlockHeight uint32

	// the request resolved by the report
	Request *ScanRequest
}

type ScanRequest

type ScanRequest struct {
	StartHeight  uint32    // nil means scan from genesis block
	Item         WatchItem // item to watch
	IsPersistent bool      // if true, the request will be re-added with StartHeight = StartHeiht + 1
}

type ScanRequestOption

type ScanRequestOption func(req *ScanRequest)

func WithPersistentWatch

func WithPersistentWatch() ScanRequestOption

func WithStartBlock

func WithStartBlock(blockHeight uint32) ScanRequestOption

func WithWatchItem

func WithWatchItem(item WatchItem) ScanRequestOption

type ScannerService

type ScannerService interface {
	// Start runs a go-routine in order to handle incoming requests via Watch
	Start() (<-chan Report, error)
	// Stop the scanner
	Stop()
	// Watch add a new request to the queue
	Watch(...ScanRequestOption)
	// WatchDescriptorWallet imports wallet descriptor, generates scripts and which
	//for specific events for those scripts
	WatchDescriptorWallet(
		descriptor string,
		eventType []EventType,
		blockStart int,
	) error
}

type ScriptWatchItem

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

ScriptWatchItem is used to check if a transaction sends funds to a script

func (*ScriptWatchItem) Bytes

func (i *ScriptWatchItem) Bytes() []byte

func (*ScriptWatchItem) Match

type WatchItem

type WatchItem interface {
	// Bytes returns the element search in the block filter
	Bytes() []byte
	// Match is used to check if a transaction matches the watch item
	Match(tx *transaction.Transaction) bool
}

WatchItem is an interface containing the common methods using by Scanner to watch specific item.

func NewScriptWatchItemFromAddress

func NewScriptWatchItemFromAddress(addr string) (WatchItem, error)

Jump to

Keyboard shortcuts

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