diff --git a/cmd/loop/terms.go b/cmd/loop/terms.go index cc73660..1aeacb9 100644 --- a/cmd/loop/terms.go +++ b/cmd/loop/terms.go @@ -24,19 +24,6 @@ func terms(ctx *cli.Context) error { } defer cleanup() - req := &looprpc.TermsRequest{} - loopOutTerms, err := client.LoopOutTerms(context.Background(), req) - if err != nil { - return err - } - - loopInTerms, err := client.GetLoopInTerms( - context.Background(), &looprpc.TermsRequest{}, - ) - if err != nil { - return err - } - printTerms := func(terms *looprpc.TermsResponse) { fmt.Printf("Amount: %d - %d\n", btcutil.Amount(terms.MinSwapAmount), @@ -53,13 +40,26 @@ func terms(ctx *cli.Context) error { fmt.Println("Loop Out") fmt.Println("--------") - printTerms(loopOutTerms) + req := &looprpc.TermsRequest{} + loopOutTerms, err := client.LoopOutTerms(context.Background(), req) + if err != nil { + fmt.Println(err) + } else { + printTerms(loopOutTerms) + } fmt.Println() fmt.Println("Loop In") fmt.Println("------") - printTerms(loopInTerms) + loopInTerms, err := client.GetLoopInTerms( + context.Background(), &looprpc.TermsRequest{}, + ) + if err != nil { + fmt.Println(err) + } else { + printTerms(loopInTerms) + } return nil } diff --git a/cmd/loopd/swapclient_server.go b/cmd/loopd/swapclient_server.go index 0557f97..391f346 100644 --- a/cmd/loopd/swapclient_server.go +++ b/cmd/loopd/swapclient_server.go @@ -6,6 +6,8 @@ import ( "fmt" "sort" + "github.com/btcsuite/btcd/chaincfg" + "github.com/lightningnetwork/lnd/queue" "github.com/lightninglabs/loop" @@ -19,6 +21,10 @@ import ( const completedSwapsCount = 5 +var ( + errNoMainnet = errors.New("function not available on mainnet") +) + // swapClientServer implements the grpc service exposed by loopd. type swapClientServer struct { impl *loop.Client @@ -270,6 +276,10 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.Term logger.Infof("Loop in terms request received") + if s.lnd.ChainParams.Name == chaincfg.MainNetParams.Name { + return nil, errNoMainnet + } + terms, err := s.impl.LoopInTerms(ctx) if err != nil { logger.Errorf("Terms request: %v", err) @@ -291,6 +301,10 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context, logger.Infof("Loop in quote request received") + if s.lnd.ChainParams.Name == chaincfg.MainNetParams.Name { + return nil, errNoMainnet + } + quote, err := s.impl.LoopInQuote(ctx, &loop.LoopInQuoteRequest{ Amount: btcutil.Amount(req.Amt), HtlcConfTarget: defaultConfTarget, @@ -310,6 +324,10 @@ func (s *swapClientServer) LoopIn(ctx context.Context, logger.Infof("Loop in request received") + if s.lnd.ChainParams.Name == chaincfg.MainNetParams.Name { + return nil, errNoMainnet + } + req := &loop.LoopInRequest{ Amount: btcutil.Amount(in.Amt), MaxMinerFee: btcutil.Amount(in.MaxMinerFee),