From 92da6b1d44c5320cdb4681a30b12487c20fffe70 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 22 Aug 2023 16:20:33 -0700 Subject: [PATCH] multi: fix linter warnings with updated linter --- contractcourt/htlc_timeout_resolver.go | 1 - contractcourt/taproot_briefcase.go | 16 ++++++++-------- funding/manager.go | 3 ++- input/musig2.go | 2 +- itest/lnd_funding_test.go | 9 ++------- lnwallet/commitment.go | 2 +- lnwallet/rpcwallet/rpcwallet.go | 4 +++- lnwire/musig2.go | 4 ++-- lnwire/partial_sig.go | 2 +- lnwire/shutdown.go | 4 ++-- sample-lnd.conf | 2 +- 11 files changed, 23 insertions(+), 26 deletions(-) diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 863be716ab9..5611a6cb5f5 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -444,7 +444,6 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error { var inp input.Input if h.isTaproot() { - //nolint:lll inp = lnutils.Ptr(input.MakeHtlcSecondLevelTimeoutTaprootInput( h.htlcResolution.SignedTimeoutTx, h.htlcResolution.SignDetails, diff --git a/contractcourt/taproot_briefcase.go b/contractcourt/taproot_briefcase.go index e3ae4f29529..5931a4556fd 100644 --- a/contractcourt/taproot_briefcase.go +++ b/contractcourt/taproot_briefcase.go @@ -159,7 +159,7 @@ func (r *resolverCtrlBlocks) Decode(reader io.Reader) error { // resolverCtrlBlocksEncoder is a custom TLV encoder for the // resolverCtrlBlocks. -func resolverCtrlBlocksEncoder(w io.Writer, val any, buf *[8]byte) error { +func resolverCtrlBlocksEncoder(w io.Writer, val any, _ *[8]byte) error { if typ, ok := val.(*resolverCtrlBlocks); ok { return (*typ).Encode(w) } @@ -168,7 +168,7 @@ func resolverCtrlBlocksEncoder(w io.Writer, val any, buf *[8]byte) error { } // rsolverCtrlBlocksDecoder is a custom TLV decoder for the resolverCtrlBlocks. -func resolverCtrlBlocksDecoder(r io.Reader, val any, buf *[8]byte, +func resolverCtrlBlocksDecoder(r io.Reader, val any, _ *[8]byte, l uint64) error { if typ, ok := val.(*resolverCtrlBlocks); ok { @@ -259,7 +259,7 @@ func varBytesDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error { } // ctrlBlockEncoder is a custom TLV encoder for the ctrlBlocks struct. -func ctrlBlockEncoder(w io.Writer, val any, buf *[8]byte) error { +func ctrlBlockEncoder(w io.Writer, val any, _ *[8]byte) error { if t, ok := val.(**ctrlBlocks); ok { return (*t).Encode(w) } @@ -268,7 +268,7 @@ func ctrlBlockEncoder(w io.Writer, val any, buf *[8]byte) error { } // ctrlBlockDecoder is a custom TLV decoder for the ctrlBlocks struct. -func ctrlBlockDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error { +func ctrlBlockDecoder(r io.Reader, val any, _ *[8]byte, l uint64) error { if typ, ok := val.(**ctrlBlocks); ok { ctrlReader := io.LimitReader(r, int64(l)) @@ -458,7 +458,7 @@ func (h *htlcTapTweaks) Encode(w io.Writer) error { } // htlcTapTweaksEncoder is a custom TLV encoder for the htlcTapTweaks struct. -func htlcTapTweaksEncoder(w io.Writer, val any, buf *[8]byte) error { +func htlcTapTweaksEncoder(w io.Writer, val any, _ *[8]byte) error { if t, ok := val.(*htlcTapTweaks); ok { return (*t).Encode(w) } @@ -467,7 +467,7 @@ func htlcTapTweaksEncoder(w io.Writer, val any, buf *[8]byte) error { } // htlcTapTweaksDecoder is a custom TLV decoder for the htlcTapTweaks struct. -func htlcTapTweaksDecoder(r io.Reader, val any, buf *[8]byte, +func htlcTapTweaksDecoder(r io.Reader, val any, _ *[8]byte, l uint64) error { if typ, ok := val.(*htlcTapTweaks); ok { @@ -538,7 +538,7 @@ func newTapTweaks() *tapTweaks { } // tapTweaksEncoder is a custom TLV encoder for the tapTweaks struct. -func tapTweaksEncoder(w io.Writer, val any, buf *[8]byte) error { +func tapTweaksEncoder(w io.Writer, val any, _ *[8]byte) error { if t, ok := val.(**tapTweaks); ok { return (*t).Encode(w) } @@ -547,7 +547,7 @@ func tapTweaksEncoder(w io.Writer, val any, buf *[8]byte) error { } // tapTweaksDecoder is a custom TLV decoder for the tapTweaks struct. -func tapTweaksDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error { +func tapTweaksDecoder(r io.Reader, val any, _ *[8]byte, l uint64) error { if typ, ok := val.(**tapTweaks); ok { tweakReader := io.LimitReader(r, int64(l)) diff --git a/funding/manager.go b/funding/manager.go index 3f97747ea91..2e27051b646 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -1528,6 +1528,7 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer, "channel") log.Error(err) f.failFundingFlow(peer, cid, err) + return // The current variant of taproot channels can only be used with @@ -3646,7 +3647,7 @@ func genFirstStateMusigNonce(channel *channeldb.OpenChannel, // handleChannelReady finalizes the channel funding process and enables the // channel to enter normal operating mode. -func (f *Manager) handleChannelReady(peer lnpeer.Peer, +func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen msg *lnwire.ChannelReady) { defer f.wg.Done() diff --git a/input/musig2.go b/input/musig2.go index d2ff0c1d416..4f7d19c089e 100644 --- a/input/musig2.go +++ b/input/musig2.go @@ -432,7 +432,7 @@ func createContextV100RC2(privKey *btcec.PrivateKey, // draft version 0.4.0. func createContextV040(privKey *btcec.PrivateKey, allSignerPubKeys []*btcec.PublicKey, tweaks *MuSig2Tweaks, - sessionOpts ...musig2.SessionOption, + _ ...musig2.SessionOption, ) (*musig2v040.Context, *musig2v040.Session, error) { // The context keeps track of all signing keys and our local key. diff --git a/itest/lnd_funding_test.go b/itest/lnd_funding_test.go index 68bcbc10077..8e0f0fe3fc9 100644 --- a/itest/lnd_funding_test.go +++ b/itest/lnd_funding_test.go @@ -142,7 +142,7 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) { chansCommitType == lnrpc.CommitmentType_ANCHORS: case expType == lnrpc.CommitmentType_STATIC_REMOTE_KEY && - chansCommitType == lnrpc.CommitmentType_STATIC_REMOTE_KEY: + chansCommitType == lnrpc.CommitmentType_STATIC_REMOTE_KEY: //nolint:lll case expType == lnrpc.CommitmentType_LEGACY && chansCommitType == lnrpc.CommitmentType_LEGACY: @@ -221,7 +221,7 @@ func basicChannelFundingTest(ht *lntest.HarnessTest, ) // Deprecated fields. - newResp.Balance += int64(local) // nolint:staticcheck + newResp.Balance += int64(local) ht.AssertChannelBalanceResp(node, newResp) } @@ -393,11 +393,6 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) { // testChannelFundingInputTypes tests that any type of supported input type can // be used to fund channels. func testChannelFundingInputTypes(ht *lntest.HarnessTest) { - const ( - chanAmt = funding.MaxBtcFundingAmount - burnAddr = "bcrt1qxsnqpdc842lu8c0xlllgvejt6rhy49u6fmpgyz" - ) - // We'll start off by creating a node for Carol. carol := ht.NewNode("Carol", nil) diff --git a/lnwallet/commitment.go b/lnwallet/commitment.go index 151e5f21c33..43c9acc8f39 100644 --- a/lnwallet/commitment.go +++ b/lnwallet/commitment.go @@ -211,7 +211,7 @@ func (w *WitnessScriptDesc) WitnessScriptToSign() []byte { // An error is returned if the path is unknown. This is useful as when // constructing a contrl block for a given path, one also needs witness script // being signed. -func (w *WitnessScriptDesc) WitnessScriptForPath(path input.ScriptPath, +func (w *WitnessScriptDesc) WitnessScriptForPath(_ input.ScriptPath, ) ([]byte, error) { return w.WitnessScript, nil diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index 92dfa644505..f8201905f5f 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -657,13 +657,15 @@ func (r *RPCKeyRing) ComputeInputScript(tx *wire.MsgTx, func (r *RPCKeyRing) MuSig2CreateSession(bipVersion input.MuSig2Version, keyLoc keychain.KeyLocator, pubKeys []*btcec.PublicKey, tweaks *input.MuSig2Tweaks, otherNonces [][musig2.PubNonceSize]byte, - sessionOpts ...musig2.SessionOption) (*input.MuSig2SessionInfo, error) { + _ ...musig2.SessionOption) (*input.MuSig2SessionInfo, error) { apiVersion, err := signrpc.MarshalMuSig2Version(bipVersion) if err != nil { return nil, err } + // TODO(roasbeef): add protos to specify session options + // We need to serialize all data for the RPC call. We can do that by // putting everything directly into the request struct. req := &signrpc.MuSig2SessionRequest{ diff --git a/lnwire/musig2.go b/lnwire/musig2.go index 8062a1a7d71..6602ee6947a 100644 --- a/lnwire/musig2.go +++ b/lnwire/musig2.go @@ -26,7 +26,7 @@ func (m *Musig2Nonce) Record() tlv.Record { } // nonceTypeEncoder is a custom TLV encoder for the Musig2Nonce type. -func nonceTypeEncoder(w io.Writer, val interface{}, buf *[8]byte) error { +func nonceTypeEncoder(w io.Writer, val interface{}, _ *[8]byte) error { if v, ok := val.(*Musig2Nonce); ok { _, err := w.Write(v[:]) return err @@ -36,7 +36,7 @@ func nonceTypeEncoder(w io.Writer, val interface{}, buf *[8]byte) error { } // nonceTypeDecoder is a custom TLV decoder for the Musig2Nonce record. -func nonceTypeDecoder(r io.Reader, val interface{}, buf *[8]byte, +func nonceTypeDecoder(r io.Reader, val interface{}, _ *[8]byte, l uint64) error { if v, ok := val.(*Musig2Nonce); ok { diff --git a/lnwire/partial_sig.go b/lnwire/partial_sig.go index fa05950ab2d..e460270f1e6 100644 --- a/lnwire/partial_sig.go +++ b/lnwire/partial_sig.go @@ -137,7 +137,7 @@ func (p *PartialSigWithNonce) Record() tlv.Record { // partialSigWithNonceTypeEncoder encodes 98-byte musig2 extended partial // signature as: s {32} || nonce {66}. func partialSigWithNonceTypeEncoder(w io.Writer, val interface{}, - buf *[8]byte) error { + _ *[8]byte) error { if v, ok := val.(*PartialSigWithNonce); ok { sigBytes := v.Sig.Bytes() diff --git a/lnwire/shutdown.go b/lnwire/shutdown.go index 93cc50e3929..5b59b47ab14 100644 --- a/lnwire/shutdown.go +++ b/lnwire/shutdown.go @@ -29,7 +29,7 @@ func (s *ShutdownNonce) Record() tlv.Record { // shutdownNonceTypeEncoder is a custom TLV encoder for the Musig2Nonce type. func shutdownNonceTypeEncoder(w io.Writer, val interface{}, - buf *[8]byte) error { + _ *[8]byte) error { if v, ok := val.(*ShutdownNonce); ok { _, err := w.Write(v[:]) @@ -40,7 +40,7 @@ func shutdownNonceTypeEncoder(w io.Writer, val interface{}, } // shutdownNonceTypeDecoder is a custom TLV decoder for the Musig2Nonce record. -func shutdownNonceTypeDecoder(r io.Reader, val interface{}, buf *[8]byte, +func shutdownNonceTypeDecoder(r io.Reader, val interface{}, _ *[8]byte, l uint64) error { if v, ok := val.(*ShutdownNonce); ok { diff --git a/sample-lnd.conf b/sample-lnd.conf index 66b83fbdcce..5d0dd4a48f8 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -1462,7 +1462,7 @@ ; Set to enable support for the experimental taproot channel type. -; protocol.simple-taproot-chans +; protocol.simple-taproot-chans=false [db]