@@ -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,16 @@ 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
+ ChainParams : d .lnd .ChainParams ,
587
+ }
588
+ hyperloopManager = hyperloop .NewManager (hyperloopConfig )
572
589
}
573
590
574
591
// Now finally fully initialize the swap client RPC server instance.
@@ -584,6 +601,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
584
601
mainCtx : d .mainCtx ,
585
602
reservationManager : reservationManager ,
586
603
instantOutManager : instantOutManager ,
604
+ hyperloopManager : hyperloopManager ,
587
605
}
588
606
589
607
// Retrieve all currently existing swaps from the database.
@@ -728,6 +746,34 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
728
746
}
729
747
}
730
748
749
+ // Start the hyperloop manager.
750
+ if d .hyperloopManager != nil {
751
+ d .wg .Add (1 )
752
+ go func () {
753
+ defer d .wg .Done ()
754
+
755
+ log .Info ("Starting hyperloop manager" )
756
+ defer log .Info ("Hyperloop manager stopped" )
757
+
758
+ // We need to know the current block height to properly
759
+ // initialize the hyperloop manager.
760
+ getInfo , err := d .lnd .Client .GetInfo (d .mainCtx )
761
+ if err != nil {
762
+ d .internalErrChan <- err
763
+ return
764
+ }
765
+
766
+ err = d .hyperloopManager .Run (
767
+ d .mainCtx , int32 (getInfo .BlockHeight ),
768
+ )
769
+ if err != nil && ! errors .Is (err , context .Canceled ) {
770
+ log .Errorf ("Error running hyperloop manager:" +
771
+ " %v" , err )
772
+ d .internalErrChan <- err
773
+ }
774
+ }()
775
+ }
776
+
731
777
// Last, start our internal error handler. This will return exactly one
732
778
// error or nil on the main error channel to inform the caller that
733
779
// something went wrong or that shutdown is complete. We don't add to
0 commit comments