scanner

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 13 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
	SpentUtxo
)

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 {
	// ClientID of the client sending request
	ClientID uuid.UUID
	// StartHeight from which scan should be performed, nil means scan from genesis block
	StartHeight uint32
	// Item to watch
	Item WatchItem
	// IsPersistent if true, the request will be re-added with StartHeight = StartHeiht + 1
	IsPersistent bool
}

type ScanRequestOption

type ScanRequestOption func(req *ScanRequest)

func WithPersistentWatch

func WithPersistentWatch() ScanRequestOption

func WithRequestID added in v0.1.2

func WithRequestID(id uuid.UUID) ScanRequestOption

func WithStartBlock

func WithStartBlock(blockHeight uint32) ScanRequestOption

func WithWatchItem

func WithWatchItem(item WatchItem) ScanRequestOption

type Service added in v0.1.2

type Service 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(
		requestID uuid.UUID,
		descriptor string,
		eventType []EventType,
		blockStart int,
	) error
}

func New

type SpentWatchItem added in v0.1.2

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

SpentWatchItem is used to watch for spent utxos.

func (*SpentWatchItem) Bytes added in v0.1.2

func (o *SpentWatchItem) Bytes() []byte

func (*SpentWatchItem) EventType added in v0.1.2

func (o *SpentWatchItem) EventType() EventType

func (*SpentWatchItem) Match added in v0.1.2

type UnspentWatchItem added in v0.1.2

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

UnspentWatchItem is used to recognise new unspent output related to a specific address/script

func (*UnspentWatchItem) Bytes added in v0.1.2

func (u *UnspentWatchItem) Bytes() []byte

func (*UnspentWatchItem) EventType added in v0.1.2

func (u *UnspentWatchItem) EventType() EventType

func (*UnspentWatchItem) Match added in v0.1.2

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
	// EventType returns the type of event that will be reported by the scanner
	EventType() EventType
}

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

func NewSpentWatchItemFromInput added in v0.1.2

func NewSpentWatchItemFromInput(
	input *transaction.TxInput,
	prevoutScript []byte,
) (WatchItem, error)

func NewUnspentWatchItemFromAddress added in v0.1.2

func NewUnspentWatchItemFromAddress(addr string) (WatchItem, error)

Jump to

Keyboard shortcuts

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