@@ -21,6 +21,7 @@ import (
2121 "github.com/lightninglabs/loop/loopd/perms"
2222 "github.com/lightninglabs/loop/loopdb"
2323 loop_looprpc "github.com/lightninglabs/loop/looprpc"
24+ "github.com/lightninglabs/loop/notifications"
2425 loop_swaprpc "github.com/lightninglabs/loop/swapserverrpc"
2526 "github.com/lightninglabs/loop/sweepbatcher"
2627 "github.com/lightningnetwork/lnd/clock"
@@ -498,21 +499,53 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
498499 }
499500 }
500501
502+ // Start the notification manager.
503+ notificationCfg := & notifications.Config {
504+ Client : loop_swaprpc .NewSwapServerClient (swapClient .Conn ),
505+ FetchL402 : swapClient .Server .FetchL402 ,
506+ }
507+ notificationManager := notifications .NewManager (notificationCfg )
508+
509+ d .wg .Add (1 )
510+ initChan := make (chan struct {})
511+ go func () {
512+ defer d .wg .Done ()
513+
514+ log .Info ("Starting notification manager" )
515+ err := notificationManager .Run (d .mainCtx , initChan )
516+ if err != nil {
517+ d .internalErrChan <- err
518+ log .Errorf ("Notification manager stopped: %v" , err )
519+ }
520+ }()
521+
522+ select {
523+ case <- time .After (10 * time .Second ):
524+ return fmt .Errorf ("notification manager not ready" )
525+
526+ case <- d .mainCtx .Done ():
527+ return nil
528+
529+ case <- initChan :
530+ }
531+
501532 var (
502533 reservationManager * reservation.Manager
503534 instantOutManager * instantout.Manager
504535 )
536+
505537 // Create the reservation and instantout managers.
506538 if d .cfg .EnableExperimental {
507539 reservationStore := reservation .NewSQLStore (
508540 loopdb.NewTypedStore [reservation.Querier ](baseDb ),
509541 )
510542 reservationConfig := & reservation.Config {
511- Store : reservationStore ,
512- Wallet : d .lnd .WalletKit ,
513- ChainNotifier : d .lnd .ChainNotifier ,
514- ReservationClient : reservationClient ,
515- FetchL402 : swapClient .Server .FetchL402 ,
543+ Store : reservationStore ,
544+ Wallet : d .lnd .WalletKit ,
545+ ChainNotifier : d .lnd .ChainNotifier ,
546+ ReservationClient : reservationClient ,
547+ FetchL402 : swapClient .Server .FetchL402 ,
548+ NotificationManager : notificationManager ,
516549 }
517550
518551 reservationManager = reservation .NewManager (
0 commit comments