chain

package
v0.0.0-...-9d10bbe Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBitcoinSubscriber

func NewBitcoinSubscriber(rpcUrl string) *bitcoinSubscriber

func NewEthereumMainnetSubscriber

func NewEthereumMainnetSubscriber(rpcUrl string, opts ...EthereumMainnetSubscriberOption) *ethereumMainnetSubscriber

func NewSolanaMainnetSubscriber

func NewSolanaMainnetSubscriber(rpcUrl string) *solanaMainnetSubscriber

Types

type ChainName

type ChainName string
const (
	EthereumMainnet ChainName = "ethereum_mainnet"
	Bitcoin         ChainName = "bitcoin"
	SolanaMainnet   ChainName = "solana_mainnet"
)

type EthereumMainnetSubscriberOption

type EthereumMainnetSubscriberOption interface {
	Apply(*ethereumMainnetSubscriber)
}

type SubscriberManager

type SubscriberManager interface {
	WalletTransactionTracker

	// RegisterSubscribers registers new subscribers and calls its Init.
	// RegisterSubscriber should not be called concurrently.
	RegisterSubscribers(subscribers ...TransactionSubscriber) error

	// StartAll accepts a sink which will receive all tracked wallet events from
	// all of the registered subscribers. StartAll blocks and exits with an
	// error if something goes wrong in one of the registered subscribers.
	StartAll(sink chan<- *TrackedWalletEvent) error
}

SubscriberManager manages all blockchain transaction subscribers within the application

func NewSubsciberManager

func NewSubsciberManager() SubscriberManager

type TrackedWalletEvent

type TrackedWalletEvent struct {
	ChainName   ChainName
	Source      string
	Destination string
	Amount      *big.Int
	Fees        *big.Int
}

TrackedWalletEvent represents a tracked wallet event. For bitcoin events, Source will contain a string of comma separated addresses. For solana events, if amount is sender's value, Source will be a single wallet address and Destination will contain comma separated recipient addresses. If amount is recipient's value, Source will contain comma separated sender addresses and Destination will be a single wallet address. For solana, Fees will be non 0 only for fee payer Source.

type TransactionSubscriber

type TransactionSubscriber interface {
	// Init initializes the subscriber, sets up any required connections and
	// prepares the subscriber to start receiving messages.
	Init() error

	// Start starts the subscriber. Returned channel will produce events
	// whenever a transaction for one of the registered wallets is received from
	// RPC provider. Start does not block.
	Start() (<-chan *TrackedWalletEvent, <-chan error)

	// TrackWallet starts to track transactions of provided wallet
	TrackWallet(wallet string) error

	// UntrackWallet stops tracking wallet's transactions
	UntrackWallet(wallet string) error

	// Name returns the chain name of given TransactionSubscriber
	Name() ChainName
}

TransactionSubscriber subscribes to real time chain data for a particular blockchain.

type WalletTransactionTracker

type WalletTransactionTracker interface {
	// TrackWallet starts tracking wallet's transactions within the given chain
	// subscriber.
	TrackWallet(wallet string, chain ChainName) error

	// UntrackWallet stops tracking wallet's transactions within the given chain
	// subscriber.
	UntrackWallet(wallet string, chain ChainName) error
}

type WithRpcClientOptions

type WithRpcClientOptions struct {
	Opts []rpc.ClientOption
}

func (WithRpcClientOptions) Apply

func (w WithRpcClientOptions) Apply(e *ethereumMainnetSubscriber)

Jump to

Keyboard shortcuts

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