mirror of
https://github.com/lightninglabs/loop
synced 2024-11-09 19:10:47 +00:00
ad7cdc8ed2
Since the code for creating and using a macaroon service is the same for multiple projects (pool, loop, litd etc), the code has been unified in lndclient. So this commit removes the macaroon service code and instead uses the lndclient code.
43 lines
1005 B
Go
43 lines
1005 B
Go
//go:build dev
|
|
// +build dev
|
|
|
|
package loopd
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
|
|
|
"github.com/lightninglabs/lndclient"
|
|
"github.com/lightninglabs/loop/looprpc"
|
|
)
|
|
|
|
var (
|
|
debugRequiredPermissions = map[string][]bakery.Op{
|
|
"/looprpc.Debug/ForceAutoLoop": {{
|
|
Entity: "debug",
|
|
Action: "write",
|
|
}},
|
|
}
|
|
)
|
|
|
|
// registerDebugServer registers the debug server.
|
|
func (d *Daemon) registerDebugServer() {
|
|
looprpc.RegisterDebugServer(d.grpcServer, d)
|
|
}
|
|
|
|
// ForceAutoLoop triggers our liquidity manager to dispatch an automated swap,
|
|
// if one is suggested. This endpoint is only for testing purposes and cannot be
|
|
// used on mainnet.
|
|
func (s *swapClientServer) ForceAutoLoop(ctx context.Context,
|
|
_ *looprpc.ForceAutoLoopRequest) (*looprpc.ForceAutoLoopResponse, error) {
|
|
|
|
if s.network == lndclient.NetworkMainnet {
|
|
return nil, fmt.Errorf("force autoloop not allowed on mainnet")
|
|
}
|
|
|
|
err := s.liquidityMgr.ForceAutoLoop(ctx)
|
|
return &looprpc.ForceAutoLoopResponse{}, err
|
|
}
|