@@ -16,6 +16,7 @@ import (
16
16
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
17
17
"github.com/lightninglabs/lndclient"
18
18
"github.com/lightninglabs/loop"
19
+ "github.com/lightninglabs/loop/hyperloop"
19
20
"github.com/lightninglabs/loop/instantout"
20
21
"github.com/lightninglabs/loop/instantout/reservation"
21
22
"github.com/lightninglabs/loop/loopd/perms"
@@ -441,6 +442,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
441
442
swapClient .Conn ,
442
443
)
443
444
445
+ // Create a hyperloop server client.
446
+ hyperloopClient := loop_swaprpc .NewHyperloopServerClient (
447
+ swapClient .Conn ,
448
+ )
449
+
444
450
// Both the client RPC server and the swap server client should stop
445
451
// on main context cancel. So we create it early and pass it down.
446
452
d .mainCtx , d .mainCtxCancel = context .WithCancel (context .Background ())
@@ -501,6 +507,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
501
507
var (
502
508
reservationManager * reservation.Manager
503
509
instantOutManager * instantout.Manager
510
+ hyperloopManager * hyperloop.Manager
504
511
)
505
512
// Create the reservation and instantout managers.
506
513
if d .cfg .EnableExperimental {
@@ -540,6 +547,15 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
540
547
instantOutManager = instantout .NewInstantOutManager (
541
548
instantOutConfig ,
542
549
)
550
+
551
+ hyperloopConfig := & hyperloop.Config {
552
+ Wallet : d .lnd .WalletKit ,
553
+ ChainNotifier : d .lnd .ChainNotifier ,
554
+ Signer : d .lnd .Signer ,
555
+ Router : d .lnd .Router ,
556
+ HyperloopClient : hyperloopClient ,
557
+ }
558
+ hyperloopManager = hyperloop .NewManager (hyperloopConfig )
543
559
}
544
560
545
561
// Now finally fully initialize the swap client RPC server instance.
@@ -555,6 +571,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
555
571
mainCtx : d .mainCtx ,
556
572
reservationManager : reservationManager ,
557
573
instantOutManager : instantOutManager ,
574
+ hyperloopManager : hyperloopManager ,
558
575
}
559
576
560
577
// Retrieve all currently existing swaps from the database.
@@ -684,6 +701,23 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
684
701
}
685
702
}
686
703
704
+ // Start the hyperloop manager.
705
+ if d .hyperloopManager != nil {
706
+ d .wg .Add (1 )
707
+ go func () {
708
+ defer d .wg .Done ()
709
+
710
+ log .Info ("Starting hyperloop manager" )
711
+ defer log .Info ("Hyperloop manager stopped" )
712
+
713
+ err := d .hyperloopManager .Run (d .mainCtx )
714
+ if err != nil && ! errors .Is (err , context .Canceled ) {
715
+ log .Errorf ("Error running hyperloop manager: %v" , err )
716
+ d .internalErrChan <- err
717
+ }
718
+ }()
719
+ }
720
+
687
721
// Last, start our internal error handler. This will return exactly one
688
722
// error or nil on the main error channel to inform the caller that
689
723
// something went wrong or that shutdown is complete. We don't add to
0 commit comments