mirror of https://github.com/lightninglabs/loop
commit
ed98051daf
@ -0,0 +1,25 @@
|
||||
language: go
|
||||
cache:
|
||||
directories:
|
||||
- $GOCACHE
|
||||
- $GOPATH/pkg/mod
|
||||
- $GOPATH/src/github.com/btcsuite
|
||||
- $GOPATH/src/github.com/golang
|
||||
- $GOPATH/src/gopkg.in/alecthomas
|
||||
|
||||
go:
|
||||
- "1.11.x"
|
||||
|
||||
env:
|
||||
global:
|
||||
- GOCACHE=$HOME/.go-build
|
||||
|
||||
sudo: required
|
||||
|
||||
script:
|
||||
- export GO111MODULE=on
|
||||
- make unit
|
||||
|
||||
after_script:
|
||||
- echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'"
|
||||
- echo "Uploading to file.io..." && tar -zcvO *.log | curl -s -F 'file=@-;filename=logs.tar.gz' https://file.io | xargs -r0 printf 'logs.tar.gz uploaded to %s\n'
|
@ -0,0 +1,15 @@
|
||||
PKG := github.com/lightninglabs/loop
|
||||
|
||||
GOTEST := GO111MODULE=on go test -v
|
||||
|
||||
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
||||
|
||||
XARGS := xargs -L 1
|
||||
|
||||
TEST_FLAGS = -test.timeout=20m
|
||||
|
||||
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
|
||||
|
||||
unit:
|
||||
@$(call print, "Running unit tests.")
|
||||
$(UNIT)
|
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var monitorCommand = cli.Command{
|
||||
Name: "monitor",
|
||||
Usage: "monitor progress of any active swaps",
|
||||
Description: "Allows the user to monitor progress of any active swaps",
|
||||
Action: monitor,
|
||||
}
|
||||
|
||||
func monitor(ctx *cli.Context) error {
|
||||
client, cleanup, err := getClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
stream, err := client.Monitor(
|
||||
context.Background(), &looprpc.MonitorRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
swap, err := stream.Recv()
|
||||
if err != nil {
|
||||
return fmt.Errorf("recv: %v", err)
|
||||
}
|
||||
logSwap(swap)
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var termsCommand = cli.Command{
|
||||
Name: "terms",
|
||||
Usage: "show current server swap terms",
|
||||
Action: terms,
|
||||
}
|
||||
|
||||
func terms(ctx *cli.Context) error {
|
||||
client, cleanup, err := getClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
terms, err := client.GetLoopOutTerms(
|
||||
context.Background(), &looprpc.TermsRequest{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Amount: %d - %d\n",
|
||||
btcutil.Amount(terms.MinSwapAmount),
|
||||
btcutil.Amount(terms.MaxSwapAmount),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printTerms := func(terms *looprpc.TermsResponse) {
|
||||
fmt.Printf("Amount: %d - %d\n",
|
||||
btcutil.Amount(terms.MinSwapAmount),
|
||||
btcutil.Amount(terms.MaxSwapAmount),
|
||||
)
|
||||
fmt.Printf("Fee: %d + %.4f %% (%d prepaid)\n",
|
||||
btcutil.Amount(terms.SwapFeeBase),
|
||||
swap.FeeRateAsPercentage(terms.SwapFeeRate),
|
||||
btcutil.Amount(terms.PrepayAmt),
|
||||
)
|
||||
|
||||
fmt.Printf("Cltv delta: %v blocks\n", terms.CltvDelta)
|
||||
}
|
||||
|
||||
fmt.Println("Loop Out")
|
||||
fmt.Println("--------")
|
||||
printTerms(terms)
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
type lndConfig struct {
|
||||
Host string `long:"host" description:"lnd instance rpc address"`
|
||||
MacaroonPath string `long:"macaroonpath" description:"Path to lnd macaroon"`
|
||||
TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"`
|
||||
}
|
||||
|
||||
type viewParameters struct{}
|
||||
|
||||
type config struct {
|
||||
Insecure bool `long:"insecure" description:"disable tls"`
|
||||
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
|
||||
SwapServer string `long:"swapserver" description:"swap server address host:port"`
|
||||
Listen string `long:"listen" description:"address to listen on for rpc lcients"`
|
||||
|
||||
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
|
||||
|
||||
View viewParameters `command:"view" alias:"v" description:"View all swaps in the database. This command can only be executed when loopd is not running."`
|
||||
}
|
||||
|
||||
var defaultConfig = config{
|
||||
Network: "mainnet",
|
||||
SwapServer: "swap.lightning.today:11009",
|
||||
Listen: "localhost:11010",
|
||||
Insecure: false,
|
||||
Lnd: &lndConfig{
|
||||
Host: "localhost:10009",
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue