@@ -16,6 +16,7 @@ import (
1616 proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
1717 "github.com/lightninglabs/lndclient"
1818 "github.com/lightninglabs/loop"
19+ "github.com/lightninglabs/loop/hyperloop"
1920 "github.com/lightninglabs/loop/instantout"
2021 "github.com/lightninglabs/loop/instantout/reservation"
2122 "github.com/lightninglabs/loop/loopd/perms"
@@ -441,6 +442,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
441442 swapClient .Conn ,
442443 )
443444
445+ // Create a hyperloop server client.
446+ hyperloopClient := loop_swaprpc .NewHyperloopServerClient (
447+ swapClient .Conn ,
448+ )
449+
444450 // Both the client RPC server and the swap server client should stop
445451 // on main context cancel. So we create it early and pass it down.
446452 d .mainCtx , d .mainCtxCancel = context .WithCancel (context .Background ())
@@ -501,6 +507,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
501507 var (
502508 reservationManager * reservation.Manager
503509 instantOutManager * instantout.Manager
510+ hyperloopManager * hyperloop.Manager
504511 )
505512 // Create the reservation and instantout managers.
506513 if d .cfg .EnableExperimental {
@@ -540,6 +547,15 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
540547 instantOutManager = instantout .NewInstantOutManager (
541548 instantOutConfig ,
542549 )
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 )
543559 }
544560
545561 // Now finally fully initialize the swap client RPC server instance.
@@ -555,6 +571,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
555571 mainCtx : d .mainCtx ,
556572 reservationManager : reservationManager ,
557573 instantOutManager : instantOutManager ,
574+ hyperloopManager : hyperloopManager ,
558575 }
559576
560577 // Retrieve all currently existing swaps from the database.
@@ -684,6 +701,23 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
684701 }
685702 }
686703
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+
687721 // Last, start our internal error handler. This will return exactly one
688722 // error or nil on the main error channel to inform the caller that
689723 // something went wrong or that shutdown is complete. We don't add to
0 commit comments