mirror of
https://github.com/lightninglabs/loop
synced 2024-11-04 06:00:21 +00:00
Merge pull request #99 from guggero/persistent-logger
multi: add persistent logger
This commit is contained in:
commit
9e5c66c051
@ -38,6 +38,9 @@ linters:
|
||||
# the linter.
|
||||
- prealloc
|
||||
|
||||
# Init functions are used by loggers throughout the codebase.
|
||||
- gochecknoinits
|
||||
|
||||
issues:
|
||||
# Only show newly introduced problems.
|
||||
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250
|
||||
|
22
client.go
22
client.go
@ -192,7 +192,7 @@ func (s *Client) Run(ctx context.Context,
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetInfo error: %v", err)
|
||||
}
|
||||
logger.Infof("Connected to lnd node %v with pubkey %v",
|
||||
log.Infof("Connected to lnd node %v with pubkey %v",
|
||||
info.Alias, hex.EncodeToString(info.IdentityPubkey[:]),
|
||||
)
|
||||
|
||||
@ -235,22 +235,22 @@ func (s *Client) Run(ctx context.Context,
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("Swap client terminating: %v", err)
|
||||
log.Errorf("Swap client terminating: %v", err)
|
||||
} else {
|
||||
logger.Info("Swap client terminating")
|
||||
log.Info("Swap client terminating")
|
||||
}
|
||||
|
||||
// Cancel all remaining active goroutines.
|
||||
mainCancel()
|
||||
|
||||
// Wait for all to finish.
|
||||
logger.Debug("Wait for executor to finish")
|
||||
log.Debug("Wait for executor to finish")
|
||||
s.executor.waitFinished()
|
||||
|
||||
logger.Debug("Wait for goroutines to finish")
|
||||
log.Debug("Wait for goroutines to finish")
|
||||
s.wg.Wait()
|
||||
|
||||
logger.Info("Swap client terminated")
|
||||
log.Info("Swap client terminated")
|
||||
|
||||
return err
|
||||
}
|
||||
@ -270,7 +270,7 @@ func (s *Client) resumeSwaps(ctx context.Context,
|
||||
}
|
||||
swap, err := resumeLoopOutSwap(ctx, swapCfg, pend)
|
||||
if err != nil {
|
||||
logger.Errorf("resuming loop out swap: %v", err)
|
||||
log.Errorf("resuming loop out swap: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ func (s *Client) resumeSwaps(ctx context.Context,
|
||||
}
|
||||
swap, err := resumeLoopInSwap(ctx, swapCfg, pend)
|
||||
if err != nil {
|
||||
logger.Errorf("resuming loop in swap: %v", err)
|
||||
log.Errorf("resuming loop in swap: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ func (s *Client) resumeSwaps(ctx context.Context,
|
||||
func (s *Client) LoopOut(globalCtx context.Context,
|
||||
request *OutRequest) (*lntypes.Hash, btcutil.Address, error) {
|
||||
|
||||
logger.Infof("LoopOut %v to %v (channel: %v)",
|
||||
log.Infof("LoopOut %v to %v (channel: %v)",
|
||||
request.Amount, request.DestAddr,
|
||||
request.LoopOutChannel,
|
||||
)
|
||||
@ -358,7 +358,7 @@ func (s *Client) LoopOutQuote(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Infof("Offchain swap destination: %x", quote.SwapPaymentDest)
|
||||
log.Infof("Offchain swap destination: %x", quote.SwapPaymentDest)
|
||||
|
||||
swapFee := quote.SwapFee
|
||||
|
||||
@ -418,7 +418,7 @@ func (s *Client) waitForInitialized(ctx context.Context) error {
|
||||
func (s *Client) LoopIn(globalCtx context.Context,
|
||||
request *LoopInRequest) (*lntypes.Hash, btcutil.Address, error) {
|
||||
|
||||
logger.Infof("Loop in %v (channel: %v)",
|
||||
log.Infof("Loop in %v (channel: %v)",
|
||||
request.Amount,
|
||||
request.LoopInChannel,
|
||||
)
|
||||
|
@ -1,5 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
)
|
||||
|
||||
var (
|
||||
loopDirBase = btcutil.AppDataDir("loop", false)
|
||||
|
||||
defaultLogLevel = "info"
|
||||
defaultLogDirname = "logs"
|
||||
defaultLogFilename = "loopd.log"
|
||||
defaultLogDir = filepath.Join(loopDirBase, defaultLogDirname)
|
||||
|
||||
defaultMaxLogFiles = 3
|
||||
defaultMaxLogFileSize = 10
|
||||
)
|
||||
|
||||
type lndConfig struct {
|
||||
Host string `long:"host" description:"lnd instance rpc address"`
|
||||
MacaroonDir string `long:"macaroondir" description:"Path to the directory containing all the required lnd macaroons"`
|
||||
@ -16,6 +34,12 @@ type config struct {
|
||||
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
|
||||
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
|
||||
|
||||
LogDir string `long:"logdir" description:"Directory to log output."`
|
||||
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
|
||||
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
|
||||
|
||||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
||||
|
||||
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."`
|
||||
@ -27,10 +51,14 @@ const (
|
||||
)
|
||||
|
||||
var defaultConfig = config{
|
||||
Network: "mainnet",
|
||||
RPCListen: "localhost:11010",
|
||||
RESTListen: "localhost:8081",
|
||||
Insecure: false,
|
||||
Network: "mainnet",
|
||||
RPCListen: "localhost:11010",
|
||||
RESTListen: "localhost:8081",
|
||||
Insecure: false,
|
||||
LogDir: defaultLogDir,
|
||||
MaxLogFiles: defaultMaxLogFiles,
|
||||
MaxLogFileSize: defaultMaxLogFileSize,
|
||||
DebugLevel: defaultLogLevel,
|
||||
Lnd: &lndConfig{
|
||||
Host: "localhost:10009",
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ func daemon(config *config) error {
|
||||
}
|
||||
}
|
||||
|
||||
logger.Infof("Swap server address: %v", config.SwapServer)
|
||||
log.Infof("Swap server address: %v", config.SwapServer)
|
||||
|
||||
// Create an instance of the loop client library.
|
||||
swapClient, cleanup, err := getClient(
|
||||
@ -73,7 +73,7 @@ func daemon(config *config) error {
|
||||
looprpc.RegisterSwapClientServer(grpcServer, &server)
|
||||
|
||||
// Next, start the gRPC server listening for HTTP/2 connections.
|
||||
logger.Infof("Starting gRPC listener")
|
||||
log.Infof("Starting gRPC listener")
|
||||
grpcListener, err := net.Listen("tcp", config.RPCListen)
|
||||
if err != nil {
|
||||
return fmt.Errorf("RPC server unable to listen on %s",
|
||||
@ -95,7 +95,7 @@ func daemon(config *config) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Infof("Starting REST proxy listener")
|
||||
log.Infof("Starting REST proxy listener")
|
||||
restListener, err := net.Listen("tcp", config.RESTListen)
|
||||
if err != nil {
|
||||
return fmt.Errorf("REST proxy unable to listen on %s",
|
||||
@ -115,14 +115,14 @@ func daemon(config *config) error {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
logger.Infof("Starting swap client")
|
||||
log.Infof("Starting swap client")
|
||||
err := swapClient.Run(mainCtx, statusChan)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
logger.Infof("Swap client stopped")
|
||||
log.Infof("Swap client stopped")
|
||||
|
||||
logger.Infof("Stopping gRPC server")
|
||||
log.Infof("Stopping gRPC server")
|
||||
grpcServer.Stop()
|
||||
|
||||
cancel()
|
||||
@ -133,7 +133,7 @@ func daemon(config *config) error {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
logger.Infof("Waiting for updates")
|
||||
log.Infof("Waiting for updates")
|
||||
for {
|
||||
select {
|
||||
case swap := <-statusChan:
|
||||
@ -160,12 +160,12 @@ func daemon(config *config) error {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
logger.Infof("RPC server listening on %s", grpcListener.Addr())
|
||||
logger.Infof("REST proxy listening on %s", restListener.Addr())
|
||||
log.Infof("RPC server listening on %s", grpcListener.Addr())
|
||||
log.Infof("REST proxy listening on %s", restListener.Addr())
|
||||
|
||||
err = grpcServer.Serve(grpcListener)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -175,7 +175,7 @@ func daemon(config *config) error {
|
||||
// Run until the users terminates loopd or an error occurred.
|
||||
select {
|
||||
case <-interruptChannel:
|
||||
logger.Infof("Received SIGINT (Ctrl+C).")
|
||||
log.Infof("Received SIGINT (Ctrl+C).")
|
||||
|
||||
// TODO: Remove debug code.
|
||||
// Debug code to dump goroutines on hanging exit.
|
||||
|
@ -1,24 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/lndclient"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
// log is a logger that is initialized with no output filters. This means the
|
||||
// package will not perform any logging by default until the caller requests
|
||||
// it.
|
||||
var (
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
logger = backendLog.Logger("LOOPD")
|
||||
logWriter = build.NewRotatingLogWriter()
|
||||
|
||||
log = build.NewSubLogger("LOOPD", logWriter.GenSubLogger)
|
||||
)
|
||||
|
||||
// logWriter implements an io.Writer that outputs to both standard output and
|
||||
// the write-end pipe of an initialized log rotator.
|
||||
type logWriter struct{}
|
||||
|
||||
func (logWriter) Write(p []byte) (n int, err error) {
|
||||
os.Stdout.Write(p)
|
||||
return len(p), nil
|
||||
func init() {
|
||||
setSubLogger("LOOPD", log, nil)
|
||||
addSubLogger("LOOP", loop.UseLogger)
|
||||
addSubLogger("LNDC", lndclient.UseLogger)
|
||||
addSubLogger("STORE", loopdb.UseLogger)
|
||||
}
|
||||
|
||||
// addSubLogger is a helper method to conveniently create and register the
|
||||
// logger of a sub system.
|
||||
func addSubLogger(subsystem string, useLogger func(btclog.Logger)) {
|
||||
logger := build.NewSubLogger(subsystem, logWriter.GenSubLogger)
|
||||
setSubLogger(subsystem, logger, useLogger)
|
||||
}
|
||||
|
||||
// setSubLogger is a helper method to conveniently register the logger of a sub
|
||||
// system.
|
||||
func setSubLogger(subsystem string, logger btclog.Logger,
|
||||
useLogger func(btclog.Logger)) {
|
||||
|
||||
logWriter.RegisterSubLogger(subsystem, logger)
|
||||
if useLogger != nil {
|
||||
useLogger(logger)
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,9 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/jessevdk/go-flags"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
)
|
||||
|
||||
@ -19,7 +18,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
loopDirBase = btcutil.AppDataDir("loop", false)
|
||||
defaultConfigFilename = "loopd.conf"
|
||||
|
||||
swaps = make(map[lntypes.Hash]loop.SwapInfo)
|
||||
@ -81,8 +79,32 @@ func start() error {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if config.DebugLevel == "show" {
|
||||
fmt.Printf("Supported subsystems: %v\n",
|
||||
logWriter.SupportedSubsystems())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Append the network type to the log directory so it is
|
||||
// "namespaced" per network in the same fashion as the data directory.
|
||||
config.LogDir = filepath.Join(config.LogDir, config.Network)
|
||||
|
||||
// Initialize logging at the default logging level.
|
||||
err = logWriter.InitLogRotator(
|
||||
filepath.Join(config.LogDir, defaultLogFilename),
|
||||
config.MaxLogFileSize, config.MaxLogFiles,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = build.ParseAndSetDebugLevels(config.DebugLevel, logWriter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Print the version before executing either primary directive.
|
||||
logger.Infof("Version: %v", loop.Version())
|
||||
log.Infof("Version: %v", loop.Version())
|
||||
|
||||
// Execute command.
|
||||
if parser.Active == nil {
|
||||
|
@ -40,7 +40,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
||||
in *looprpc.LoopOutRequest) (
|
||||
*looprpc.SwapResponse, error) {
|
||||
|
||||
logger.Infof("Loop out request received")
|
||||
log.Infof("Loop out request received")
|
||||
|
||||
sweepConfTarget, err := validateConfTarget(
|
||||
in.SweepConfTarget, loop.DefaultSweepConfTarget,
|
||||
@ -82,7 +82,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
||||
}
|
||||
hash, htlc, err := s.impl.LoopOut(ctx, req)
|
||||
if err != nil {
|
||||
logger.Errorf("LoopOut: %v", err)
|
||||
log.Errorf("LoopOut: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
|
||||
func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest,
|
||||
server looprpc.SwapClient_MonitorServer) error {
|
||||
|
||||
logger.Infof("Monitor request received")
|
||||
log.Infof("Monitor request received")
|
||||
|
||||
send := func(info loop.SwapInfo) error {
|
||||
rpcSwap, err := s.marshallSwap(&info)
|
||||
@ -234,11 +234,11 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest,
|
||||
func (s *swapClientServer) LoopOutTerms(ctx context.Context,
|
||||
req *looprpc.TermsRequest) (*looprpc.TermsResponse, error) {
|
||||
|
||||
logger.Infof("Loop out terms request received")
|
||||
log.Infof("Loop out terms request received")
|
||||
|
||||
terms, err := s.impl.LoopOutTerms(ctx)
|
||||
if err != nil {
|
||||
logger.Errorf("Terms request: %v", err)
|
||||
log.Errorf("Terms request: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -280,11 +280,11 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
|
||||
func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.TermsRequest) (
|
||||
*looprpc.TermsResponse, error) {
|
||||
|
||||
logger.Infof("Loop in terms request received")
|
||||
log.Infof("Loop in terms request received")
|
||||
|
||||
terms, err := s.impl.LoopInTerms(ctx)
|
||||
if err != nil {
|
||||
logger.Errorf("Terms request: %v", err)
|
||||
log.Errorf("Terms request: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context, req *looprpc.Term
|
||||
func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
|
||||
req *looprpc.QuoteRequest) (*looprpc.QuoteResponse, error) {
|
||||
|
||||
logger.Infof("Loop in quote request received")
|
||||
log.Infof("Loop in quote request received")
|
||||
|
||||
quote, err := s.impl.LoopInQuote(ctx, &loop.LoopInQuoteRequest{
|
||||
Amount: btcutil.Amount(req.Amt),
|
||||
@ -318,7 +318,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
|
||||
in *looprpc.LoopInRequest) (
|
||||
*looprpc.SwapResponse, error) {
|
||||
|
||||
logger.Infof("Loop in request received")
|
||||
log.Infof("Loop in request received")
|
||||
|
||||
req := &loop.LoopInRequest{
|
||||
Amount: btcutil.Amount(in.Amt),
|
||||
@ -332,7 +332,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
|
||||
}
|
||||
hash, htlc, err := s.impl.LoopIn(ctx, req)
|
||||
if err != nil {
|
||||
logger.Errorf("Loop in: %v", err)
|
||||
log.Errorf("Loop in: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ func (s *executor) run(mainCtx context.Context,
|
||||
// Before starting, make sure we have an up to date block height.
|
||||
// Otherwise we might reveal a preimage for a swap that is already
|
||||
// expired.
|
||||
logger.Infof("Wait for first block ntfn")
|
||||
log.Infof("Wait for first block ntfn")
|
||||
|
||||
var height int32
|
||||
setHeight := func(h int32) {
|
||||
@ -77,7 +77,7 @@ func (s *executor) run(mainCtx context.Context,
|
||||
}
|
||||
|
||||
// Start main event loop.
|
||||
logger.Infof("Starting event loop at height %v", height)
|
||||
log.Infof("Starting event loop at height %v", height)
|
||||
|
||||
// Signal that executor being ready with an up to date block height.
|
||||
close(s.ready)
|
||||
|
4
go.mod
4
go.mod
@ -1,7 +1,7 @@
|
||||
module github.com/lightninglabs/loop
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3
|
||||
github.com/btcsuite/btcd v0.20.0-beta
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
||||
github.com/coreos/bbolt v1.3.3
|
||||
@ -10,7 +10,7 @@ require (
|
||||
github.com/google/go-cmp v0.3.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.10.0
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/lightningnetwork/lnd v0.7.1-beta-rc2.0.20190914085956-35027e52fc22
|
||||
github.com/lightningnetwork/lnd v0.8.0-beta-rc3.0.20191025122959-1a0ab538d53c
|
||||
github.com/lightningnetwork/lnd/queue v1.0.1
|
||||
github.com/urfave/cli v1.20.0
|
||||
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
|
||||
|
21
go.sum
21
go.sum
@ -13,7 +13,9 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmH
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
||||
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
@ -22,12 +24,14 @@ github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8 h1:mOg8/RgDSHTQ1R0IR
|
||||
github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
||||
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3 h1:A/EVblehb75cUgXA5njHPn0kLAsykn6mJGz7rnmW5W0=
|
||||
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
||||
github.com/btcsuite/btcd v0.20.0-beta h1:DnZGUjFbRkpytojHWwy6nfUSA7vFrzWXDLpFNzt74ZA=
|
||||
github.com/btcsuite/btcd v0.20.0-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||
github.com/btcsuite/btcwallet v0.0.0-20190911065739-d5cdeb4b91b0 h1:S9+cnZ7N4EvkkOBQ3lUy4p7+XjW4GS81R4QjwuT06Cw=
|
||||
github.com/btcsuite/btcwallet v0.0.0-20190911065739-d5cdeb4b91b0/go.mod h1:ntLqUbZ12G8FmPX1nJj7W83WiAFOLRGiuarH4zDYdlI=
|
||||
github.com/btcsuite/btcwallet v0.10.0 h1:fFZncfYJ7VByePTGttzJc3qfCyDzU95ucZYk0M912lU=
|
||||
github.com/btcsuite/btcwallet v0.10.0/go.mod h1:4TqBEuceheGNdeLNrelliLHJzmXauMM2vtWfuy1pFiM=
|
||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0 h1:KGHMW5sd7yDdDMkCZ/JpP0KltolFsQcB973brBnfj4c=
|
||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
||||
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0 h1:2VsfS0sBedcM5KmDzRMT3+b6xobqWveZGvjb+jFez5w=
|
||||
@ -36,6 +40,8 @@ github.com/btcsuite/btcwallet/wallet/txsizes v1.0.0 h1:6DxkcoMnCPY4E9cUDPB5tbuuf
|
||||
github.com/btcsuite/btcwallet/wallet/txsizes v1.0.0/go.mod h1:pauEU8UuMFiThe5PB3EO+gO5kx87Me5NvdQDsTuq6cs=
|
||||
github.com/btcsuite/btcwallet/walletdb v1.0.0 h1:mheT7vCWK5EP6rZzhxsQ7ms9+yX4VE8bwiJctECBeNw=
|
||||
github.com/btcsuite/btcwallet/walletdb v1.0.0/go.mod h1:bZTy9RyYZh9fLnSua+/CD48TJtYJSHjjYcSaszuxCCk=
|
||||
github.com/btcsuite/btcwallet/walletdb v1.1.0 h1:JHAL7wZ8pX4SULabeAv/wPO9sseRWMGzE80lfVmRw6Y=
|
||||
github.com/btcsuite/btcwallet/walletdb v1.1.0/go.mod h1:bZTy9RyYZh9fLnSua+/CD48TJtYJSHjjYcSaszuxCCk=
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.0.0 h1:aIHgViEmZmZfe0tQQqF1xyd2qBqFWxX5vZXkkbjtbeA=
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.0.0/go.mod h1:vc4gBprll6BP0UJ+AIGDaySoc7MdAmZf8kelfNb8CFY=
|
||||
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY=
|
||||
@ -131,6 +137,7 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfM
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec h1:n1NeQ3SgUHyISrjFFoO5dR748Is8dBL9qpaTNfphQrs=
|
||||
github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
@ -140,12 +147,12 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lightninglabs/gozmq v0.0.0-20190710231225-cea2a031735d h1:tt8hwvxl6fksSfchjBGaWu+pnWJQfG1OWiCM20qOSAE=
|
||||
github.com/lightninglabs/gozmq v0.0.0-20190710231225-cea2a031735d/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
|
||||
github.com/lightninglabs/neutrino v0.0.0-20190906012717-f087198de655 h1:/EpOX/6QvD5CdoAfMt1yvZeUPjJ8sCiHv6CRNG2lEuY=
|
||||
github.com/lightninglabs/neutrino v0.0.0-20190906012717-f087198de655/go.mod h1:awTrhbCWjWNH4yVwZ4IE7nZbvpQ27e7OyD+jao7wRxA=
|
||||
github.com/lightninglabs/neutrino v0.10.0 h1:yWVy2cOCCXbKFdpYCE9vD1fWRJDd9FtGXhUws4l9RkU=
|
||||
github.com/lightninglabs/neutrino v0.10.0/go.mod h1:C3KhCMk1Mcx3j8v0qRVWM1Ow6rIJSvSPnUAq00ZNAfk=
|
||||
github.com/lightningnetwork/lightning-onion v0.0.0-20190909101754-850081b08b6a h1:GoWPN4i4jTKRxhVNh9a2vvBBO1Y2seiJB+SopUYoKyo=
|
||||
github.com/lightningnetwork/lightning-onion v0.0.0-20190909101754-850081b08b6a/go.mod h1:rigfi6Af/KqsF7Za0hOgcyq2PNH4AN70AaMRxcJkff4=
|
||||
github.com/lightningnetwork/lnd v0.7.1-beta-rc2.0.20190914085956-35027e52fc22 h1:PWCIRUyow3Od4TMukVHL5jmNhjUPKhw6OVVruYCCUQ0=
|
||||
github.com/lightningnetwork/lnd v0.7.1-beta-rc2.0.20190914085956-35027e52fc22/go.mod h1:VaY0b5o38keUN3Ga6GVb/Mgta4B/CcCXwNvPAvhbv/A=
|
||||
github.com/lightningnetwork/lnd v0.8.0-beta-rc3.0.20191025122959-1a0ab538d53c h1:eZcbiUop12hTTVIjicfm85do4kftmJqAwGVWYPh6+Xo=
|
||||
github.com/lightningnetwork/lnd v0.8.0-beta-rc3.0.20191025122959-1a0ab538d53c/go.mod h1:nq06y2BDv7vwWeMmwgB7P3pT7/Uj7sGf5FzHISVD6t4=
|
||||
github.com/lightningnetwork/lnd/queue v1.0.1 h1:jzJKcTy3Nj5lQrooJ3aaw9Lau3I0IwvQR5sqtjdv2R0=
|
||||
github.com/lightningnetwork/lnd/queue v1.0.1/go.mod h1:vaQwexir73flPW43Mrm7JOgJHmcEFBWWSl9HlyASoms=
|
||||
github.com/lightningnetwork/lnd/ticker v1.0.0 h1:S1b60TEGoTtCe2A0yeB+ecoj/kkS4qpwh6l+AkQEZwU=
|
||||
@ -184,6 +191,7 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sK
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@ -263,6 +271,7 @@ google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
|
@ -253,7 +253,7 @@ func (s *lightningClient) payInvoice(ctx context.Context, invoice string,
|
||||
|
||||
// Paid successfully.
|
||||
case PaymentResultSuccess:
|
||||
logger.Infof(
|
||||
log.Infof(
|
||||
"Payment %v completed", hash,
|
||||
)
|
||||
|
||||
@ -274,7 +274,7 @@ func (s *lightningClient) payInvoice(ctx context.Context, invoice string,
|
||||
|
||||
// Invoice was already paid on a previous run.
|
||||
case PaymentResultAlreadyPaid:
|
||||
logger.Infof(
|
||||
log.Infof(
|
||||
"Payment %v already completed", hash,
|
||||
)
|
||||
|
||||
@ -294,7 +294,7 @@ func (s *lightningClient) payInvoice(ctx context.Context, invoice string,
|
||||
// TODO: Improve this when lnd expose more API to
|
||||
// tracking existing payments.
|
||||
case PaymentResultInFlight:
|
||||
logger.Infof(
|
||||
log.Infof(
|
||||
"Payment %v already in flight", hash,
|
||||
)
|
||||
|
||||
@ -302,7 +302,7 @@ func (s *lightningClient) payInvoice(ctx context.Context, invoice string,
|
||||
|
||||
// Other errors are transformed into an error struct.
|
||||
default:
|
||||
logger.Warnf(
|
||||
log.Warnf(
|
||||
"Payment %v failed: %v", hash,
|
||||
payResp.PaymentError,
|
||||
)
|
||||
|
@ -84,13 +84,13 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
|
||||
}
|
||||
|
||||
// Setup connection with lnd
|
||||
logger.Infof("Creating lnd connection to %v", lndAddress)
|
||||
log.Infof("Creating lnd connection to %v", lndAddress)
|
||||
conn, err := getClientConn(lndAddress, network, tlsPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Infof("Connected to lnd")
|
||||
log.Infof("Connected to lnd")
|
||||
|
||||
chainParams, err := swap.ChainParamsFromNetwork(network)
|
||||
if err != nil {
|
||||
@ -125,19 +125,19 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
|
||||
routerClient := newRouterClient(conn, macaroons.routerMac)
|
||||
|
||||
cleanup := func() {
|
||||
logger.Debugf("Closing lnd connection")
|
||||
log.Debugf("Closing lnd connection")
|
||||
conn.Close()
|
||||
|
||||
logger.Debugf("Wait for client to finish")
|
||||
log.Debugf("Wait for client to finish")
|
||||
lightningClient.WaitForFinished()
|
||||
|
||||
logger.Debugf("Wait for chain notifier to finish")
|
||||
log.Debugf("Wait for chain notifier to finish")
|
||||
notifierClient.WaitForFinished()
|
||||
|
||||
logger.Debugf("Wait for invoices to finish")
|
||||
log.Debugf("Wait for invoices to finish")
|
||||
invoicesClient.WaitForFinished()
|
||||
|
||||
logger.Debugf("Lnd services finished")
|
||||
log.Debugf("Lnd services finished")
|
||||
}
|
||||
|
||||
services := &GrpcLndServices{
|
||||
@ -154,7 +154,7 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
|
||||
cleanup: cleanup,
|
||||
}
|
||||
|
||||
logger.Infof("Using network %v", network)
|
||||
log.Infof("Using network %v", network)
|
||||
|
||||
return services, nil
|
||||
}
|
||||
@ -164,7 +164,7 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
|
||||
func (s *GrpcLndServices) Close() {
|
||||
s.cleanup()
|
||||
|
||||
logger.Debugf("Lnd services finished")
|
||||
log.Debugf("Lnd services finished")
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -1,24 +1,23 @@
|
||||
package lndclient
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
// means the package will not perform any logging by default until the caller
|
||||
// requests it.
|
||||
var (
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
logger = backendLog.Logger("LNDCLIENT")
|
||||
)
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
// means the package will not perform any logging by default until the
|
||||
// caller requests it.
|
||||
var log btclog.Logger
|
||||
|
||||
// logWriter implements an io.Writer that outputs to both standard output and
|
||||
// the write-end pipe of an initialized log rotator.
|
||||
type logWriter struct{}
|
||||
|
||||
func (logWriter) Write(p []byte) (n int, err error) {
|
||||
os.Stdout.Write(p)
|
||||
return len(p), nil
|
||||
// The default amount of logging is none.
|
||||
func init() {
|
||||
UseLogger(build.NewSubLogger("LNDC", nil))
|
||||
}
|
||||
|
||||
// UseLogger uses a specified Logger to output package logging info.
|
||||
// This should be used in preference to SetLogWriter if the caller is also
|
||||
// using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
31
log.go
31
log.go
@ -1,24 +1,23 @@
|
||||
package loop
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
// means the package will not perform any logging by default until the caller
|
||||
// requests it.
|
||||
var (
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
logger = backendLog.Logger("CLIENT")
|
||||
)
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
// means the package will not perform any logging by default until the
|
||||
// caller requests it.
|
||||
var log btclog.Logger
|
||||
|
||||
// logWriter implements an io.Writer that outputs to both standard output and
|
||||
// the write-end pipe of an initialized log rotator.
|
||||
type logWriter struct{}
|
||||
|
||||
func (logWriter) Write(p []byte) (n int, err error) {
|
||||
os.Stdout.Write(p)
|
||||
return len(p), nil
|
||||
// The default amount of logging is none.
|
||||
func init() {
|
||||
UseLogger(build.NewSubLogger("LOOP", nil))
|
||||
}
|
||||
|
||||
// UseLogger uses a specified Logger to output package logging info.
|
||||
// This should be used in preference to SetLogWriter if the caller is also
|
||||
// using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
@ -1,21 +1,23 @@
|
||||
package loopdb
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
var (
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
log = backendLog.Logger("STORE")
|
||||
)
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
// means the package will not perform any logging by default until the
|
||||
// caller requests it.
|
||||
var log btclog.Logger
|
||||
|
||||
// logWriter implements an io.Writer that outputs to both standard output and
|
||||
// the write-end pipe of an initialized log rotator.
|
||||
type logWriter struct{}
|
||||
|
||||
func (logWriter) Write(p []byte) (n int, err error) {
|
||||
os.Stdout.Write(p)
|
||||
return len(p), nil
|
||||
// The default amount of logging is none.
|
||||
func init() {
|
||||
UseLogger(build.NewSubLogger("STORE", nil))
|
||||
}
|
||||
|
||||
// UseLogger uses a specified Logger to output package logging info.
|
||||
// This should be used in preference to SetLogWriter if the caller is also
|
||||
// using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
|
||||
swapFee := quote.SwapFee
|
||||
|
||||
if swapFee > request.MaxSwapFee {
|
||||
logger.Warnf("Swap fee %v exceeding maximum of %v",
|
||||
log.Warnf("Swap fee %v exceeding maximum of %v",
|
||||
swapFee, request.MaxSwapFee)
|
||||
|
||||
return nil, ErrSwapFeeTooHigh
|
||||
@ -81,7 +81,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
|
||||
// Generate random preimage.
|
||||
var swapPreimage lntypes.Preimage
|
||||
if _, err := rand.Read(swapPreimage[:]); err != nil {
|
||||
logger.Error("Cannot generate preimage")
|
||||
log.Error("Cannot generate preimage")
|
||||
}
|
||||
swapHash := lntypes.Hash(sha256.Sum256(swapPreimage[:]))
|
||||
|
||||
@ -111,7 +111,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
|
||||
// Post the swap parameters to the swap server. The response contains
|
||||
// the server success key and the expiry height of the on-chain swap
|
||||
// htlc.
|
||||
logger.Infof("Initiating swap request at height %v", currentHeight)
|
||||
log.Infof("Initiating swap request at height %v", currentHeight)
|
||||
swapResp, err := cfg.server.NewLoopInSwap(globalCtx, swapHash,
|
||||
request.Amount, senderKey, swapInvoice,
|
||||
)
|
||||
@ -179,7 +179,7 @@ func resumeLoopInSwap(reqContext context.Context, cfg *swapConfig,
|
||||
|
||||
hash := lntypes.Hash(sha256.Sum256(pend.Contract.Preimage[:]))
|
||||
|
||||
logger.Infof("Resuming loop in swap %v", hash)
|
||||
log.Infof("Resuming loop in swap %v", hash)
|
||||
|
||||
swapKit, err := newSwapKit(
|
||||
hash, swap.TypeIn, cfg, &pend.Contract.SwapContract,
|
||||
|
@ -52,7 +52,7 @@ func TestLoopInSuccess(t *testing.T) {
|
||||
go func() {
|
||||
err := swap.execute(context.Background(), ctx.cfg, height)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
@ -142,7 +142,7 @@ func TestLoopInTimeout(t *testing.T) {
|
||||
go func() {
|
||||
err := swap.execute(context.Background(), ctx.cfg, height)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
@ -289,7 +289,7 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool) {
|
||||
go func() {
|
||||
err := swap.execute(context.Background(), ctx.cfg, height)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
|
16
loopout.go
16
loopout.go
@ -61,7 +61,7 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
|
||||
// Generate random preimage.
|
||||
var swapPreimage [32]byte
|
||||
if _, err := rand.Read(swapPreimage[:]); err != nil {
|
||||
logger.Error("Cannot generate preimage")
|
||||
log.Error("Cannot generate preimage")
|
||||
}
|
||||
swapHash := lntypes.Hash(sha256.Sum256(swapPreimage[:]))
|
||||
|
||||
@ -77,7 +77,7 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
|
||||
|
||||
// Post the swap parameters to the swap server. The response contains
|
||||
// the server revocation key and the swap and prepay invoices.
|
||||
logger.Infof("Initiating swap request at height %v", currentHeight)
|
||||
log.Infof("Initiating swap request at height %v", currentHeight)
|
||||
|
||||
swapResp, err := cfg.server.NewLoopOutSwap(globalCtx, swapHash,
|
||||
request.Amount, receiverKey,
|
||||
@ -147,7 +147,7 @@ func resumeLoopOutSwap(reqContext context.Context, cfg *swapConfig,
|
||||
|
||||
hash := lntypes.Hash(sha256.Sum256(pend.Contract.Preimage[:]))
|
||||
|
||||
logger.Infof("Resuming loop out swap %v", hash)
|
||||
log.Infof("Resuming loop out swap %v", hash)
|
||||
|
||||
swapKit, err := newSwapKit(
|
||||
hash, swap.TypeOut, cfg, &pend.Contract.SwapContract,
|
||||
@ -309,7 +309,7 @@ func (s *loopOutSwap) executeSwap(globalCtx context.Context) error {
|
||||
|
||||
// Verify amount if preimage hasn't been revealed yet.
|
||||
if s.state != loopdb.StatePreimageRevealed && htlcValue < s.AmountRequested {
|
||||
logger.Warnf("Swap amount too low, expected %v but received %v",
|
||||
log.Warnf("Swap amount too low, expected %v but received %v",
|
||||
s.AmountRequested, htlcValue)
|
||||
|
||||
s.state = loopdb.StateFailInsufficientValue
|
||||
@ -494,7 +494,7 @@ func (s *loopOutSwap) waitForConfirmedHtlc(globalCtx context.Context) (
|
||||
case notification := <-s.blockEpochChan:
|
||||
s.height = notification.(int32)
|
||||
|
||||
logger.Infof("Received block %v", s.height)
|
||||
log.Infof("Received block %v", s.height)
|
||||
|
||||
if checkMaxRevealHeightExceeded() {
|
||||
return nil, nil
|
||||
@ -690,21 +690,21 @@ func validateLoopOutContract(lnd *lndclient.LndServices,
|
||||
|
||||
swapFee := swapInvoiceAmt + prepayInvoiceAmt - request.Amount
|
||||
if swapFee > request.MaxSwapFee {
|
||||
logger.Warnf("Swap fee %v exceeding maximum of %v",
|
||||
log.Warnf("Swap fee %v exceeding maximum of %v",
|
||||
swapFee, request.MaxSwapFee)
|
||||
|
||||
return ErrSwapFeeTooHigh
|
||||
}
|
||||
|
||||
if prepayInvoiceAmt > request.MaxPrepayAmount {
|
||||
logger.Warnf("Prepay amount %v exceeding maximum of %v",
|
||||
log.Warnf("Prepay amount %v exceeding maximum of %v",
|
||||
prepayInvoiceAmt, request.MaxPrepayAmount)
|
||||
|
||||
return ErrPrepayAmountTooHigh
|
||||
}
|
||||
|
||||
if response.expiry-height < MinLoopOutPreimageRevealDelta {
|
||||
logger.Warnf("Proposed expiry %v (delta %v) too soon",
|
||||
log.Warnf("Proposed expiry %v (delta %v) too soon",
|
||||
response.expiry, response.expiry-height)
|
||||
|
||||
return ErrExpiryTooSoon
|
||||
|
@ -62,7 +62,7 @@ func TestLateHtlcPublish(t *testing.T) {
|
||||
timerFactory: timerFactory,
|
||||
}, height)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
@ -153,7 +153,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
||||
sweeper: sweeper,
|
||||
}, ctx.Lnd.Height)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
log.Error(err)
|
||||
}
|
||||
errChan <- err
|
||||
}()
|
||||
|
2
swap.go
2
swap.go
@ -44,7 +44,7 @@ func newSwapKit(hash lntypes.Hash, swapType swap.Type, cfg *swapConfig,
|
||||
|
||||
log := &swap.PrefixLog{
|
||||
Hash: hash,
|
||||
Logger: logger,
|
||||
Logger: log,
|
||||
}
|
||||
|
||||
// Log htlc address for debugging.
|
||||
|
@ -114,7 +114,7 @@ func createClientTestContext(t *testing.T,
|
||||
runCtx,
|
||||
statusChan,
|
||||
)
|
||||
logger.Errorf("client run: %v", err)
|
||||
log.Errorf("client run: %v", err)
|
||||
ctx.runErr <- err
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user