From a1271fee400ef714a6bc25d2ffa48b3ecf032e6f Mon Sep 17 00:00:00 2001 From: sputn1ck Date: Fri, 20 May 2022 08:57:06 +0200 Subject: [PATCH] multi: fix linter issues --- cmd/loop/liquidity.go | 1 - cmd/loop/loopout.go | 2 +- cmd/loop/lsat.go | 1 - cmd/loop/swaps.go | 2 +- interface.go | 2 +- liquidity/liquidity.go | 1 - liquidity/liquidity_test.go | 2 -- liquidity/threshold_rule.go | 1 - loopd/run.go | 1 + loopd/swapclient_server.go | 1 - loopdb/raw_db_test.go | 4 +--- loopdb/store_test.go | 1 - loopin_test.go | 1 - loopout_test.go | 1 + swap/htlc.go | 2 +- swap/htlc_test.go | 3 +-- swap/log.go | 1 - test/lightning_client_mock.go | 4 ++-- 18 files changed, 10 insertions(+), 21 deletions(-) diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index 27ae09c..a494190 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -476,7 +476,6 @@ func setParams(ctx *cli.Context) error { // so that it does not need to be manually updated. case categoriesSet: params.FeePpm = 0 - } // Update our parameters to our mutated values. _, err = client.SetLiquidityParams( diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 7670c76..fd945ea 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -161,7 +161,7 @@ func loopOut(ctx *cli.Context) error { } // Show a warning if a slow swap was requested. - warning := "" + var warning string if fast { warning = "Fast swap requested." } else { diff --git a/cmd/loop/lsat.go b/cmd/loop/lsat.go index bd2dc45..2898c9a 100644 --- a/cmd/loop/lsat.go +++ b/cmd/loop/lsat.go @@ -49,7 +49,6 @@ func listAuth(ctx *cli.Context) error { tokens := make([]*printableToken, len(resp.Tokens)) for i, t := range resp.Tokens { - mac := &macaroon.Macaroon{} err := mac.UnmarshalBinary(t.BaseMacaroon) if err != nil { diff --git a/cmd/loop/swaps.go b/cmd/loop/swaps.go index 80df2e5..dfab471 100644 --- a/cmd/loop/swaps.go +++ b/cmd/loop/swaps.go @@ -60,7 +60,7 @@ func swapInfo(ctx *cli.Context) error { id = ctx.String("id") case ctx.NArg() > 0: id = args[0] - args = args.Tail() + args = args.Tail() // nolint:wastedassign default: // Show command help if no arguments and flags were provided. return cli.ShowCommandHelp(ctx, "swapinfo") diff --git a/interface.go b/interface.go index 813f742..54e4687 100644 --- a/interface.go +++ b/interface.go @@ -305,7 +305,7 @@ type LoopInSwapInfo struct { // nolint // LoopOutSwapInfo contains essential information of a loop-out swap after the // swap is initiated. -type LoopOutSwapInfo struct { // nolint:golint +type LoopOutSwapInfo struct { // nolint:revive // SwapHash contains the sha256 hash of the swap preimage. SwapHash lntypes.Hash diff --git a/liquidity/liquidity.go b/liquidity/liquidity.go index 54f3935..0b3f0d4 100644 --- a/liquidity/liquidity.go +++ b/liquidity/liquidity.go @@ -262,7 +262,6 @@ func (p Parameters) String() string { ruleList = append( ruleList, fmt.Sprintf("Peer: %v: %v", peer, rule), ) - } return fmt.Sprintf("rules: %v, failure backoff: %v, sweep "+ diff --git a/liquidity/liquidity_test.go b/liquidity/liquidity_test.go index 4104ba0..c1fc41d 100644 --- a/liquidity/liquidity_test.go +++ b/liquidity/liquidity_test.go @@ -1409,7 +1409,6 @@ func TestSizeRestrictions(t *testing.T) { Maximum: 6000, }, nil, ).Once() - }, suggestions: nil, expectedError: ErrMaxExceedsServer, @@ -1582,7 +1581,6 @@ func TestFeePercentage(t *testing.T) { error) { return testCase.quote, nil - } lnd.Channels = []lndclient.ChannelInfo{ diff --git a/liquidity/threshold_rule.go b/liquidity/threshold_rule.go index 5390533..e8d960e 100644 --- a/liquidity/threshold_rule.go +++ b/liquidity/threshold_rule.go @@ -152,7 +152,6 @@ func calculateSwapAmount(targetAmount, reserveAmount, // cannot take any further action. case reserveAmount <= reserveMinimum: return 0 - } // Express our minimum reserve amount as a maximum target amount. diff --git a/loopd/run.go b/loopd/run.go index a694777..1122de9 100644 --- a/loopd/run.go +++ b/loopd/run.go @@ -103,6 +103,7 @@ func NewListenerConfig(config *Config, rpcCfg RPCConfig) *ListenerCfg { if rpcCfg.LndConn != nil { svcCfg.Dialer = func(context.Context, string) ( net.Conn, error) { + return rpcCfg.LndConn, nil } } diff --git a/loopd/swapclient_server.go b/loopd/swapclient_server.go index 37b83eb..22bffb7 100644 --- a/loopd/swapclient_server.go +++ b/loopd/swapclient_server.go @@ -936,7 +936,6 @@ func rpcToRule(rule *clientrpc.LiquidityRule) (*liquidity.SwapRule, error) { default: return nil, fmt.Errorf("unknown rule: %T", rule) } - } // SuggestSwaps provides a list of suggested swaps based on lnd's current diff --git a/loopdb/raw_db_test.go b/loopdb/raw_db_test.go index 52df920..27241df 100644 --- a/loopdb/raw_db_test.go +++ b/loopdb/raw_db_test.go @@ -19,7 +19,7 @@ import ( // "human-readable": Hex("102030"), // Hex("1111"): Hex("5783492373"), // }, -// } +// } . func DumpDB(tx *bbolt.Tx) error { // nolint: unused return tx.ForEach(func(k []byte, bucket *bbolt.Bucket) error { key := toString(k) @@ -95,9 +95,7 @@ func restoreDB(bucket *bbolt.Bucket, data map[string]interface{}) error { } continue } - switch value := v.(type) { - // Key contains value. case string: err := bucket.Put(key, []byte(value)) diff --git a/loopdb/store_test.go b/loopdb/store_test.go index 76edccc..3f7e11b 100644 --- a/loopdb/store_test.go +++ b/loopdb/store_test.go @@ -90,7 +90,6 @@ func TestLoopOutStore(t *testing.T) { t.Run("labelled swap", func(t *testing.T) { testLoopOutStore(t, &labelledSwap) }) - } // testLoopOutStore tests the basic functionality of the current bbolt diff --git a/loopin_test.go b/loopin_test.go index 6fe9c7e..cfe42ca 100644 --- a/loopin_test.go +++ b/loopin_test.go @@ -257,7 +257,6 @@ func testLoopInTimeout(t *testing.T, // Expect a signing request for the htlc tx output value. signReq := <-ctx.lnd.SignOutputRawChannel if signReq.SignDescriptors[0].Output.Value != htlcTx.TxOut[0].Value { - t.Fatal("invalid signing amount") } diff --git a/loopout_test.go b/loopout_test.go index 8a39464..2f153fd 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -114,6 +114,7 @@ func TestLoopOutPaymentParameters(t *testing.T) { if !reflect.DeepEqual( []uint64(req.OutgoingChanSet), swapPayment.OutgoingChanIds, ) { + t.Fatalf("Unexpected outgoing channel set") } diff --git a/swap/htlc.go b/swap/htlc.go index 60358b5..a2e7c1b 100644 --- a/swap/htlc.go +++ b/swap/htlc.go @@ -503,7 +503,7 @@ type HtlcScriptV2 struct { // OP_ELSE // OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY 1 // OP_CHECKSEQUENCEVERIFY -// OP_ENDIF +// OP_ENDIF . func newHTLCScriptV2(cltvExpiry int32, senderHtlcKey, receiverHtlcKey [33]byte, swapHash lntypes.Hash) (*HtlcScriptV2, error) { diff --git a/swap/htlc_test.go b/swap/htlc_test.go index e672217..742f677 100644 --- a/swap/htlc_test.go +++ b/swap/htlc_test.go @@ -26,7 +26,7 @@ import ( // asserting the result matches the validity expectation. In the case where it // doesn't match the expectation, it executes the script step-by-step and // prints debug information to stdout. -// This code is adopted from: lnd/input/script_utils_test.go +// This code is adopted from: lnd/input/script_utils_test.go . func assertEngineExecution(t *testing.T, valid bool, newEngine func() (*txscript.Engine, error)) { @@ -200,7 +200,6 @@ func TestHtlcV2(t *testing.T) { require.NoError(t, err) return witness - }, true, }, { diff --git a/swap/log.go b/swap/log.go index ea9789b..c45a465 100644 --- a/swap/log.go +++ b/swap/log.go @@ -41,7 +41,6 @@ func (s *PrefixLog) Errorf(format string, params ...interface{}) { fmt.Sprintf("%v %s", ShortHash(&s.Hash), format), params..., ) - } // ShortHash returns a shortened version of the hash suitable for use in diff --git a/test/lightning_client_mock.go b/test/lightning_client_mock.go index 19eb4aa..31920b2 100644 --- a/test/lightning_client_mock.go +++ b/test/lightning_client_mock.go @@ -185,7 +185,7 @@ func (h *mockLightningClient) ListTransactions( } // GetNodeInfo retrieves info on the node, and if includeChannels is True, -// will return other channels the node may have with other peers +// will return other channels the node may have with other peers. func (h *mockLightningClient) GetNodeInfo(ctx context.Context, pubKeyBytes route.Vertex, includeChannels bool) (*lndclient.NodeInfo, error) { @@ -224,7 +224,7 @@ func (h *mockLightningClient) GetNodeInfo(ctx context.Context, return nodeInfo, nil } -// GetChanInfo retrieves all the info the node has on the given channel +// GetChanInfo retrieves all the info the node has on the given channel. func (h *mockLightningClient) GetChanInfo(ctx context.Context, channelID uint64) (*lndclient.ChannelEdge, error) {