@@ -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"
@@ -450,6 +451,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
450
451
swapClient .Conn ,
451
452
)
452
453
454
+ // Create a hyperloop server client.
455
+ hyperloopClient := loop_swaprpc .NewHyperloopServerClient (
456
+ swapClient .Conn ,
457
+ )
458
+
453
459
// Both the client RPC server and the swap server client should stop
454
460
// on main context cancel. So we create it early and pass it down.
455
461
d .mainCtx , d .mainCtxCancel = context .WithCancel (context .Background ())
@@ -529,6 +535,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
529
535
var (
530
536
reservationManager * reservation.Manager
531
537
instantOutManager * instantout.Manager
538
+ hyperloopManager * hyperloop.Manager
532
539
)
533
540
534
541
// Create the reservation and instantout managers.
@@ -569,6 +576,15 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
569
576
instantOutManager = instantout .NewInstantOutManager (
570
577
instantOutConfig ,
571
578
)
579
+
580
+ hyperloopConfig := & hyperloop.Config {
581
+ Wallet : d .lnd .WalletKit ,
582
+ ChainNotifier : d .lnd .ChainNotifier ,
583
+ Signer : d .lnd .Signer ,
584
+ Router : d .lnd .Router ,
585
+ HyperloopClient : hyperloopClient ,
586
+ }
587
+ hyperloopManager = hyperloop .NewManager (hyperloopConfig )
572
588
}
573
589
574
590
// Now finally fully initialize the swap client RPC server instance.
@@ -584,6 +600,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
584
600
mainCtx : d .mainCtx ,
585
601
reservationManager : reservationManager ,
586
602
instantOutManager : instantOutManager ,
603
+ hyperloopManager : hyperloopManager ,
587
604
}
588
605
589
606
// Retrieve all currently existing swaps from the database.
@@ -728,6 +745,23 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
728
745
}
729
746
}
730
747
748
+ // Start the hyperloop manager.
749
+ if d .hyperloopManager != nil {
750
+ d .wg .Add (1 )
751
+ go func () {
752
+ defer d .wg .Done ()
753
+
754
+ log .Info ("Starting hyperloop manager" )
755
+ defer log .Info ("Hyperloop manager stopped" )
756
+
757
+ err := d .hyperloopManager .Run (d .mainCtx )
758
+ if err != nil && ! errors .Is (err , context .Canceled ) {
759
+ log .Errorf ("Error running hyperloop manager: %v" , err )
760
+ d .internalErrChan <- err
761
+ }
762
+ }()
763
+ }
764
+
731
765
// Last, start our internal error handler. This will return exactly one
732
766
// error or nil on the main error channel to inform the caller that
733
767
// something went wrong or that shutdown is complete. We don't add to
0 commit comments