loopd: hide reservation manager behind flag.

pull/632/head
sputn1ck 4 months ago
parent 30acccbb6f
commit f00329d7c7
No known key found for this signature in database
GPG Key ID: 671103D881A5F0E4

@ -168,7 +168,7 @@ type Config struct {
TotalPaymentTimeout time.Duration `long:"totalpaymenttimeout" description:"The timeout to use for off-chain payments."` TotalPaymentTimeout time.Duration `long:"totalpaymenttimeout" description:"The timeout to use for off-chain payments."`
MaxPaymentRetries int `long:"maxpaymentretries" description:"The maximum number of times an off-chain payment may be retried."` MaxPaymentRetries int `long:"maxpaymentretries" description:"The maximum number of times an off-chain payment may be retried."`
EnableExperimental bool `long:"experimental" description:"Enable experimental features: taproot HTLCs and MuSig2 loop out sweeps."` EnableExperimental bool `long:"experimental" description:"Enable experimental features: reservations"`
Lnd *lndConfig `group:"lnd" namespace:"lnd"` Lnd *lndConfig `group:"lnd" namespace:"lnd"`

@ -484,18 +484,20 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
} }
// Create the reservation rpc server. // Create the reservation rpc server.
reservationStore := reservation.NewSQLStore(baseDb) if d.cfg.EnableExperimental {
reservationConfig := &reservation.Config{ reservationStore := reservation.NewSQLStore(baseDb)
Store: reservationStore, reservationConfig := &reservation.Config{
Wallet: d.lnd.WalletKit, Store: reservationStore,
ChainNotifier: d.lnd.ChainNotifier, Wallet: d.lnd.WalletKit,
ReservationClient: reservationClient, ChainNotifier: d.lnd.ChainNotifier,
FetchL402: swapClient.Server.FetchL402, ReservationClient: reservationClient,
} FetchL402: swapClient.Server.FetchL402,
}
d.reservationManager = reservation.NewManager( d.reservationManager = reservation.NewManager(
reservationConfig, reservationConfig,
) )
}
// Now finally fully initialize the swap client RPC server instance. // Now finally fully initialize the swap client RPC server instance.
d.swapClientServer = swapClientServer{ d.swapClientServer = swapClientServer{
@ -576,28 +578,30 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}() }()
// Start the reservation manager. // Start the reservation manager.
d.wg.Add(1) if d.reservationManager != nil {
go func() { d.wg.Add(1)
defer d.wg.Done() go func() {
defer d.wg.Done()
// We need to know the current block height to properly // We need to know the current block height to properly
// initialize the reservation manager. // initialize the reservation manager.
getInfo, err := d.lnd.Client.GetInfo(d.mainCtx) getInfo, err := d.lnd.Client.GetInfo(d.mainCtx)
if err != nil { if err != nil {
d.internalErrChan <- err d.internalErrChan <- err
return return
} }
log.Info("Starting reservation manager") log.Info("Starting reservation manager")
defer log.Info("Reservation manager stopped") defer log.Info("Reservation manager stopped")
err = d.reservationManager.Run( err = d.reservationManager.Run(
d.mainCtx, int32(getInfo.BlockHeight), d.mainCtx, int32(getInfo.BlockHeight),
) )
if err != nil && !errors.Is(err, context.Canceled) { if err != nil && !errors.Is(err, context.Canceled) {
d.internalErrChan <- err d.internalErrChan <- err
} }
}() }()
}
// Last, start our internal error handler. This will return exactly one // Last, start our internal error handler. This will return exactly one
// error or nil on the main error channel to inform the caller that // error or nil on the main error channel to inform the caller that

@ -1145,6 +1145,10 @@ func (s *swapClientServer) ListReservations(ctx context.Context,
_ *clientrpc.ListReservationsRequest) ( _ *clientrpc.ListReservationsRequest) (
*clientrpc.ListReservationsResponse, error) { *clientrpc.ListReservationsResponse, error) {
if s.reservationManager == nil {
return nil, status.Error(codes.Unimplemented,
"Restart loop with --experimental")
}
reservations, err := s.reservationManager.GetReservations( reservations, err := s.reservationManager.GetReservations(
ctx, ctx,
) )

Loading…
Cancel
Save