notifications

package
v0.36.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Subsystem = "NTFNS"

Subsystem defines the sub system name of this package.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Client

type Client interface {
	// SubscribeNotifications subscribes to the notifications from the server.
	SubscribeNotifications(ctx context.Context,
		in *swapserverrpc.SubscribeNotificationsRequest,
		opts ...grpc.CallOption) (
		swapserverrpc.SwapServer_SubscribeNotificationsClient, error)
}

Client is the interface that the notification manager needs to implement in order to be able to subscribe to notifications.

type Config

type Config struct {
	// Client is the client used to communicate with the swap server.
	Client Client

	// CurrentToken returns the token that is currently contained in the
	// store or an l402.ErrNoToken error if there is none.
	CurrentToken func() (*l402.Token, error)

	// MinAliveConnTime is the minimum time that the connection to the
	// server needs to be alive before we consider it a successful.
	MinAliveConnTime time.Duration

	// MaxQueuedNotifications is the maximum number of notifications that
	// can wait in each subscriber's delivery queue.
	MaxQueuedNotifications int

	// PersistStaticLoopInRiskDecision durably records static loop-in
	// confirmation-risk decisions. If this fails, the notification is still
	// forwarded and cached subject to maxPendingRiskDecisions so a later
	// subscriber can process it after the swap row exists.
	PersistStaticLoopInRiskDecision func(context.Context, lntypes.Hash,
		bool) error
}

Config contains all the services that the notification manager needs to operate.

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager is a manager for notifications that the swap server sends to the client.

func NewManager

func NewManager(cfg *Config) *Manager

NewManager creates a new notification manager.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run starts the notification manager. It will keep on running until the context is canceled. It will subscribe to notifications and forward them to the subscribers. On a first successful connection to the server, it will close the readyChan to signal that the manager is ready.

func (*Manager) SubscribeHtlcConfirmed

func (m *Manager) SubscribeHtlcConfirmed(ctx context.Context,
) <-chan *swapserverrpc.ServerHtlcConfirmedNotification

SubscribeHtlcConfirmed subscribes to the HTLC confirmed notifications.

func (*Manager) SubscribeReservations

func (m *Manager) SubscribeReservations(ctx context.Context,
) <-chan *swapserverrpc.ServerReservationNotification

SubscribeReservations subscribes to the reservation notifications.

func (*Manager) SubscribeStaticLoopInRiskAccepted

func (m *Manager) SubscribeStaticLoopInRiskAccepted(ctx context.Context,
	swapHash lntypes.Hash,
) <-chan *swapserverrpc.ServerStaticLoopInRiskAcceptedNotification

SubscribeStaticLoopInRiskAccepted subscribes to static loop in risk accepted notifications.

func (*Manager) SubscribeStaticLoopInRiskRejected

func (m *Manager) SubscribeStaticLoopInRiskRejected(ctx context.Context,
	swapHash lntypes.Hash,
) <-chan *swapserverrpc.ServerStaticLoopInRiskRejectedNotification

SubscribeStaticLoopInRiskRejected subscribes to static loop in risk rejected notifications.

func (*Manager) SubscribeStaticLoopInSweepRequests

func (m *Manager) SubscribeStaticLoopInSweepRequests(ctx context.Context,
) <-chan *swapserverrpc.ServerStaticLoopInSweepNotification

SubscribeStaticLoopInSweepRequests subscribes to the static loop in sweep requests.

func (*Manager) SubscribeUnfinishedSwaps

func (m *Manager) SubscribeUnfinishedSwaps(ctx context.Context,
) <-chan *swapserverrpc.ServerUnfinishedSwapNotification

SubscribeUnfinishedSwaps subscribes to the unfinished swap notifications.

type NotificationType

type NotificationType int

NotificationType is the type of notification that the manager can handle.

const (
	// NotificationTypeUnknown is the default notification type.
	NotificationTypeUnknown NotificationType = iota

	// NotificationTypeReservation is the notification type for reservation
	// notifications.
	NotificationTypeReservation

	// NotificationTypeStaticLoopInSweepRequest is the notification type for
	// static loop in sweep requests.
	NotificationTypeStaticLoopInSweepRequest

	// NotificationTypeStaticLoopInRiskAccepted is the notification type for
	// static loop in confirmation risk acceptance.
	NotificationTypeStaticLoopInRiskAccepted

	// NotificationTypeStaticLoopInRiskRejected is the notification type for
	// static loop in confirmation risk rejection.
	NotificationTypeStaticLoopInRiskRejected

	// NotificationTypeUnfinishedSwap is the notification type for unfinished
	// swap notifications.
	NotificationTypeUnfinishedSwap

	// NotificationTypeHtlcConfirmed is the notification type for HTLC
	// confirmed notifications.
	NotificationTypeHtlcConfirmed
)

Jump to

Keyboard shortcuts

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