From 71bb06f6f7776d21ff4d600fcb41f10cdf33c300 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 21 Nov 2022 17:12:17 +0100 Subject: [PATCH] multi: fix linter issues, run imports --- accounting/config.go | 5 ++--- accounting/conversions.go | 1 - accounting/entries_test.go | 4 +--- accounting/filter_test.go | 1 - accounting/on_chain.go | 3 +-- accounting/report.go | 3 +-- cmd/frcli/channel_insights.go | 3 +-- cmd/frcli/close_recommendations.go | 3 +-- cmd/frcli/close_reports.go | 3 +-- cmd/frcli/fiat_estimate.go | 5 ++--- cmd/frcli/main.go | 3 +-- cmd/frcli/node_audit.go | 3 +-- cmd/frcli/revenue_report.go | 3 +-- cmd/frcli/utils.go | 10 ++++------ config.go | 3 +-- faraday.go | 5 ++--- fiat/prices.go | 3 +-- fiat/prices_test.go | 1 - frdrpcserver/close_report.go | 3 +-- frdrpcserver/node_audit.go | 5 ++--- frdrpcserver/revenue_report.go | 3 +-- frdrpcserver/rpcserver.go | 15 ++++++--------- insights/insights.go | 3 +-- insights/insights_test.go | 4 +--- itest/nodereport_test.go | 7 +++---- itest/rpc.go | 3 +-- itest/test_context.go | 3 +-- lndwrap/lndwrap.go | 3 +-- log.go | 6 +++--- resolutions/resolutions.go | 3 +-- revenue/revenue.go | 2 ++ revenue/revenue_test.go | 1 - 32 files changed, 45 insertions(+), 78 deletions(-) diff --git a/accounting/config.go b/accounting/config.go index 6b1ee01..37d5265 100644 --- a/accounting/config.go +++ b/accounting/config.go @@ -6,12 +6,11 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/lightninglabs/lndclient" - "github.com/lightningnetwork/lnd/routing/route" - "github.com/lightninglabs/faraday/fees" "github.com/lightninglabs/faraday/fiat" "github.com/lightninglabs/faraday/lndwrap" + "github.com/lightninglabs/lndclient" + "github.com/lightningnetwork/lnd/routing/route" ) // decodePaymentRequest is a signature for decoding payment requests. diff --git a/accounting/conversions.go b/accounting/conversions.go index 87baa28..8e882dc 100644 --- a/accounting/conversions.go +++ b/accounting/conversions.go @@ -5,7 +5,6 @@ import ( "time" "github.com/btcsuite/btcd/btcutil" - "github.com/lightninglabs/faraday/fiat" "github.com/lightninglabs/faraday/utils" ) diff --git a/accounting/entries_test.go b/accounting/entries_test.go index fca5387..c96e4fd 100644 --- a/accounting/entries_test.go +++ b/accounting/entries_test.go @@ -8,6 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/lightninglabs/faraday/fiat" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lntypes" @@ -15,8 +16,6 @@ import ( "github.com/lightningnetwork/lnd/routing/route" "github.com/shopspring/decimal" "github.com/stretchr/testify/require" - - "github.com/lightninglabs/faraday/fiat" ) var ( @@ -222,7 +221,6 @@ func TestChannelOpenEntry(t *testing.T) { Credit: credit, BTCPrice: mockBTCPrice, } - } feeAmt := satsToMsat(channelFeesSats) diff --git a/accounting/filter_test.go b/accounting/filter_test.go index 40f9f2f..5ebf4b3 100644 --- a/accounting/filter_test.go +++ b/accounting/filter_test.go @@ -132,7 +132,6 @@ func TestFilterOnChain(t *testing.T) { expctedAmount := payment.Amount + payment.Fee require.Equal(t, expctedAmount, filtered[0].Amount) - } // TestFilterInvoices tests filtering out of invoices that are not settled. diff --git a/accounting/on_chain.go b/accounting/on_chain.go index e218c49..7a1fa0b 100644 --- a/accounting/on_chain.go +++ b/accounting/on_chain.go @@ -5,11 +5,10 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" + "github.com/lightninglabs/faraday/utils" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" - - "github.com/lightninglabs/faraday/utils" ) // OnChainReport produces a report of our on chain activity for a period using diff --git a/accounting/report.go b/accounting/report.go index 156971e..0a0ff74 100644 --- a/accounting/report.go +++ b/accounting/report.go @@ -4,10 +4,9 @@ import ( "fmt" "time" + "github.com/lightninglabs/faraday/fiat" "github.com/lightningnetwork/lnd/lnwire" "github.com/shopspring/decimal" - - "github.com/lightninglabs/faraday/fiat" ) // Report contains a set of entries. diff --git a/cmd/frcli/channel_insights.go b/cmd/frcli/channel_insights.go index 9ca67bc..9929539 100644 --- a/cmd/frcli/channel_insights.go +++ b/cmd/frcli/channel_insights.go @@ -3,9 +3,8 @@ package main import ( "context" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday/frdrpc" + "github.com/urfave/cli" ) var channelInsightsCommand = cli.Command{ diff --git a/cmd/frcli/close_recommendations.go b/cmd/frcli/close_recommendations.go index c2d0c5d..400b7e9 100644 --- a/cmd/frcli/close_recommendations.go +++ b/cmd/frcli/close_recommendations.go @@ -5,9 +5,8 @@ import ( "fmt" "time" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday/frdrpc" + "github.com/urfave/cli" ) var ( diff --git a/cmd/frcli/close_reports.go b/cmd/frcli/close_reports.go index 04b08d0..bfed96d 100644 --- a/cmd/frcli/close_reports.go +++ b/cmd/frcli/close_reports.go @@ -3,9 +3,8 @@ package main import ( "context" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday/frdrpc" + "github.com/urfave/cli" ) var closeReportCommand = cli.Command{ diff --git a/cmd/frcli/fiat_estimate.go b/cmd/frcli/fiat_estimate.go index 84ce3ab..ad16142 100644 --- a/cmd/frcli/fiat_estimate.go +++ b/cmd/frcli/fiat_estimate.go @@ -5,12 +5,11 @@ import ( "fmt" "time" + "github.com/lightninglabs/faraday/fiat" + "github.com/lightninglabs/faraday/frdrpc" "github.com/lightningnetwork/lnd/lnwire" "github.com/shopspring/decimal" "github.com/urfave/cli" - - "github.com/lightninglabs/faraday/fiat" - "github.com/lightninglabs/faraday/frdrpc" ) var fiatBackendFlag = cli.StringFlag{ diff --git a/cmd/frcli/main.go b/cmd/frcli/main.go index 724579a..7cbff99 100644 --- a/cmd/frcli/main.go +++ b/cmd/frcli/main.go @@ -3,9 +3,8 @@ package main import ( "os" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday" + "github.com/urfave/cli" ) var ( diff --git a/cmd/frcli/node_audit.go b/cmd/frcli/node_audit.go index 8b1871d..e1170fc 100644 --- a/cmd/frcli/node_audit.go +++ b/cmd/frcli/node_audit.go @@ -9,9 +9,8 @@ import ( "strings" "time" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday/frdrpc" + "github.com/urfave/cli" ) var onChainReportCommand = cli.Command{ diff --git a/cmd/frcli/revenue_report.go b/cmd/frcli/revenue_report.go index 3cf8adf..f435bc8 100644 --- a/cmd/frcli/revenue_report.go +++ b/cmd/frcli/revenue_report.go @@ -3,9 +3,8 @@ package main import ( "context" - "github.com/urfave/cli" - "github.com/lightninglabs/faraday/frdrpc" + "github.com/urfave/cli" ) var revenueReportCommand = cli.Command{ diff --git a/cmd/frcli/utils.go b/cmd/frcli/utils.go index bc2a695..b603970 100644 --- a/cmd/frcli/utils.go +++ b/cmd/frcli/utils.go @@ -15,10 +15,12 @@ import ( "strings" "time" - "github.com/lightninglabs/faraday/utils" - "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/lightninglabs/faraday" + "github.com/lightninglabs/faraday/fiat" + "github.com/lightninglabs/faraday/frdrpc" + "github.com/lightninglabs/faraday/utils" "github.com/lightninglabs/lndclient" "github.com/lightninglabs/protobuf-hex-display/jsonpb" "github.com/lightninglabs/protobuf-hex-display/proto" @@ -28,10 +30,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" "gopkg.in/macaroon.v2" - - "github.com/lightninglabs/faraday" - "github.com/lightninglabs/faraday/fiat" - "github.com/lightninglabs/faraday/frdrpc" ) var ( diff --git a/config.go b/config.go index f27787d..967b33a 100644 --- a/config.go +++ b/config.go @@ -10,13 +10,12 @@ import ( "time" "github.com/btcsuite/btcd/btcutil" + "github.com/lightninglabs/faraday/chain" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/cert" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" "google.golang.org/grpc/credentials" - - "github.com/lightninglabs/faraday/chain" ) const ( diff --git a/faraday.go b/faraday.go index 764d48c..f3a1d60 100644 --- a/faraday.go +++ b/faraday.go @@ -8,13 +8,12 @@ import ( "strings" "github.com/jessevdk/go-flags" + "github.com/lightninglabs/faraday/chain" + "github.com/lightninglabs/faraday/frdrpcserver" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/lnrpc/verrpc" "github.com/lightningnetwork/lnd/signal" - - "github.com/lightninglabs/faraday/chain" - "github.com/lightninglabs/faraday/frdrpcserver" ) // MinLndVersion is the minimum lnd version required. Note that apis that are diff --git a/fiat/prices.go b/fiat/prices.go index 49512df..1caf947 100644 --- a/fiat/prices.go +++ b/fiat/prices.go @@ -7,10 +7,9 @@ import ( "sort" "time" + "github.com/lightninglabs/faraday/utils" "github.com/lightningnetwork/lnd/lnwire" "github.com/shopspring/decimal" - - "github.com/lightninglabs/faraday/utils" ) var ( diff --git a/fiat/prices_test.go b/fiat/prices_test.go index be00363..d4aa64c 100644 --- a/fiat/prices_test.go +++ b/fiat/prices_test.go @@ -250,6 +250,5 @@ func TestValidatePriceSourceConfig(t *testing.T) { test.expectedErr, err) } }) - } } diff --git a/frdrpcserver/close_report.go b/frdrpcserver/close_report.go index eb46b3a..699cb97 100644 --- a/frdrpcserver/close_report.go +++ b/frdrpcserver/close_report.go @@ -5,11 +5,10 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/lightninglabs/lndclient" - "github.com/lightninglabs/faraday/fees" "github.com/lightninglabs/faraday/frdrpc" "github.com/lightninglabs/faraday/resolutions" + "github.com/lightninglabs/lndclient" ) func parseCloseReportRequest(ctx context.Context, cfg *Config) *resolutions.Config { diff --git a/frdrpcserver/node_audit.go b/frdrpcserver/node_audit.go index ddba0bc..848ec0b 100644 --- a/frdrpcserver/node_audit.go +++ b/frdrpcserver/node_audit.go @@ -7,13 +7,12 @@ import ( "sort" "time" - "github.com/lightningnetwork/lnd/routing/route" - "github.com/shopspring/decimal" - "github.com/lightninglabs/faraday/accounting" "github.com/lightninglabs/faraday/fees" "github.com/lightninglabs/faraday/fiat" "github.com/lightninglabs/faraday/frdrpc" + "github.com/lightningnetwork/lnd/routing/route" + "github.com/shopspring/decimal" ) var ( diff --git a/frdrpcserver/revenue_report.go b/frdrpcserver/revenue_report.go index 75c6bf7..090f191 100644 --- a/frdrpcserver/revenue_report.go +++ b/frdrpcserver/revenue_report.go @@ -4,11 +4,10 @@ import ( "context" "time" - "github.com/lightninglabs/lndclient" - "github.com/lightninglabs/faraday/frdrpc" "github.com/lightninglabs/faraday/lndwrap" "github.com/lightninglabs/faraday/revenue" + "github.com/lightninglabs/lndclient" ) // parseRevenueRequest parses a request for a revenue report and wraps diff --git a/frdrpcserver/rpcserver.go b/frdrpcserver/rpcserver.go index 5b31344..f1e43f4 100644 --- a/frdrpcserver/rpcserver.go +++ b/frdrpcserver/rpcserver.go @@ -21,13 +21,6 @@ import ( "sync/atomic" proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/lightninglabs/lndclient" - "github.com/lightningnetwork/lnd/macaroons" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - "google.golang.org/protobuf/encoding/protojson" - "gopkg.in/macaroon-bakery.v2/bakery" - "github.com/lightninglabs/faraday/accounting" "github.com/lightninglabs/faraday/chain" "github.com/lightninglabs/faraday/fiat" @@ -36,6 +29,12 @@ import ( "github.com/lightninglabs/faraday/recommend" "github.com/lightninglabs/faraday/resolutions" "github.com/lightninglabs/faraday/revenue" + "github.com/lightninglabs/lndclient" + "github.com/lightningnetwork/lnd/macaroons" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/protobuf/encoding/protojson" + "gopkg.in/macaroon-bakery.v2/bakery" ) var ( @@ -234,7 +233,6 @@ func (s *RPCServer) Start() error { if err != nil { return fmt.Errorf("RPC RPCServer unable to listen on %v", s.cfg.RPCListen) - } shutdownFuncs["gRPC listener"] = s.rpcListener.Close log.Infof("gRPC server listening on %s", s.rpcListener.Addr()) @@ -249,7 +247,6 @@ func (s *RPCServer) Start() error { if err != nil { return fmt.Errorf("REST server unable to listen on "+ "%v: %v", s.cfg.RESTListen, err) - } restListener = tls.NewListener( restListener, s.cfg.TLSServerConfig, diff --git a/insights/insights.go b/insights/insights.go index 68d1eb9..81e6102 100644 --- a/insights/insights.go +++ b/insights/insights.go @@ -3,10 +3,9 @@ package insights import ( "time" + "github.com/lightninglabs/faraday/revenue" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/lnwire" - - "github.com/lightninglabs/faraday/revenue" ) // ChannelInfo provides a set of performance metrics for a lightning channel. diff --git a/insights/insights_test.go b/insights/insights_test.go index 08cf07f..67b77e0 100644 --- a/insights/insights_test.go +++ b/insights/insights_test.go @@ -5,10 +5,9 @@ import ( "testing" "time" + "github.com/lightninglabs/faraday/revenue" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/lnwire" - - "github.com/lightninglabs/faraday/revenue" ) // TestGetChannels tests gathering of channel insights from a set of lnrpc @@ -144,7 +143,6 @@ func TestGetChannels(t *testing.T) { insight, insights[i]) } } - }) } } diff --git a/itest/nodereport_test.go b/itest/nodereport_test.go index df78fe3..26e94b9 100644 --- a/itest/nodereport_test.go +++ b/itest/nodereport_test.go @@ -8,16 +8,15 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/lightninglabs/faraday/accounting" + "github.com/lightninglabs/faraday/fees" + "github.com/lightninglabs/faraday/frdrpc" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" "github.com/stretchr/testify/require" - - "github.com/lightninglabs/faraday/accounting" - "github.com/lightninglabs/faraday/fees" - "github.com/lightninglabs/faraday/frdrpc" ) var ( diff --git a/itest/rpc.go b/itest/rpc.go index 7622da1..aad177a 100644 --- a/itest/rpc.go +++ b/itest/rpc.go @@ -5,12 +5,11 @@ import ( "io/ioutil" "github.com/btcsuite/btcd/rpcclient" + "github.com/lightninglabs/faraday/frdrpc" "github.com/lightningnetwork/lnd/macaroons" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "gopkg.in/macaroon.v2" - - "github.com/lightninglabs/faraday/frdrpc" ) // getBitcoindClient returns an rpc client connection to the running bitcoind diff --git a/itest/test_context.go b/itest/test_context.go index daeecd3..f1f4586 100644 --- a/itest/test_context.go +++ b/itest/test_context.go @@ -13,6 +13,7 @@ import ( "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/wire" "github.com/lightninglabs/faraday" + "github.com/lightninglabs/faraday/frdrpc" "github.com/lightninglabs/lndclient" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/lnrpc" @@ -21,8 +22,6 @@ import ( "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" "github.com/stretchr/testify/require" - - "github.com/lightninglabs/faraday/frdrpc" ) var ( diff --git a/lndwrap/lndwrap.go b/lndwrap/lndwrap.go index 11b26f9..4cf631d 100644 --- a/lndwrap/lndwrap.go +++ b/lndwrap/lndwrap.go @@ -8,9 +8,8 @@ import ( "fmt" "time" - "github.com/lightninglabs/lndclient" - "github.com/lightninglabs/faraday/paginater" + "github.com/lightninglabs/lndclient" ) // ListInvoices makes paginated calls to lnd to get our full set of diff --git a/log.go b/log.go index a0ae434..4ee624b 100644 --- a/log.go +++ b/log.go @@ -2,15 +2,14 @@ package faraday import ( "github.com/btcsuite/btclog" - "github.com/lightningnetwork/lnd/build" - "github.com/lightningnetwork/lnd/signal" - "github.com/lightninglabs/faraday/accounting" "github.com/lightninglabs/faraday/dataset" "github.com/lightninglabs/faraday/fiat" "github.com/lightninglabs/faraday/frdrpcserver" "github.com/lightninglabs/faraday/recommend" "github.com/lightninglabs/faraday/revenue" + "github.com/lightningnetwork/lnd/build" + "github.com/lightningnetwork/lnd/signal" ) // Subsystem defines the logging code for this subsystem. @@ -73,6 +72,7 @@ func genSubLogger(root *build.RotatingLogWriter, // logger of a sub system. func addSubLogger(root *build.RotatingLogWriter, subsystem string, interceptor signal.Interceptor, useLogger func(btclog.Logger)) { + logger := build.NewSubLogger(subsystem, genSubLogger(root, interceptor)) setSubLogger(root, subsystem, logger, useLogger) } diff --git a/resolutions/resolutions.go b/resolutions/resolutions.go index c577f00..c3efba5 100644 --- a/resolutions/resolutions.go +++ b/resolutions/resolutions.go @@ -8,10 +8,9 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/lightninglabs/faraday/utils" "github.com/lightninglabs/lndclient" "github.com/shopspring/decimal" - - "github.com/lightninglabs/faraday/utils" ) var ( diff --git a/revenue/revenue.go b/revenue/revenue.go index 0997291..24e12b7 100644 --- a/revenue/revenue.go +++ b/revenue/revenue.go @@ -179,6 +179,7 @@ func (r Report) setRevenue(targetChan, pairChan string, // Revenue Report. func (r Report) addIncoming(incomingChannel, outgoingChannel string, amount, fees lnwire.MilliSatoshi) { + revenue := r.getRevenue(incomingChannel, outgoingChannel) // Add the fees and revenue that have been earned to the existing revenue @@ -195,6 +196,7 @@ func (r Report) addIncoming(incomingChannel, // Revenue Report. func (r Report) addOutgoing(outgoingChannel, incomingChannel string, amount, fees lnwire.MilliSatoshi) { + revenue := r.getRevenue(outgoingChannel, incomingChannel) // Add the fees and revenue that have been earned to the existing revenue diff --git a/revenue/revenue_test.go b/revenue/revenue_test.go index 5c9f0df..02f5f61 100644 --- a/revenue/revenue_test.go +++ b/revenue/revenue_test.go @@ -130,7 +130,6 @@ func TestGetRevenueReport(t *testing.T) { t.Fatalf("expected: \n%+v, got: \n%+v", test.expectedReport, report) } - }) } }