diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 25c971308c..959792881d 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -741,7 +741,7 @@ func (l *channelLink) syncChanStates() error { // very same nonce that we sent above, as they should // take the latest verification nonce we send. if chanState.ChanType.IsTaproot() { - fundingLockedMsg.NextLocalNonce = localChanSyncMsg.LocalNonce + fundingLockedMsg.NextLocalNonce = localChanSyncMsg.LocalNonce //nolint:lll } // For channels that negotiated the option-scid-alias diff --git a/lnwallet/chancloser/chancloser.go b/lnwallet/chancloser/chancloser.go index 7947f120be..a383097eb9 100644 --- a/lnwallet/chancloser/chancloser.go +++ b/lnwallet/chancloser/chancloser.go @@ -688,8 +688,6 @@ func (c *ChanCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, "new co op close offer: %w", err) } - break - // Otherwise, if we are the initiator, and we just sent a // signature for a taproot channel, then we'll ensure that the // fee rate matches up exactly. @@ -755,7 +753,7 @@ func (c *ChanCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, matchingSig := c.priorFeeOffers[remoteProposedFee] if c.cfg.Channel.ChanType().IsTaproot() { muSession := c.cfg.MusigSession - localSig, remoteSig, closeOpts, err = muSession.CombineClosingOpts( //nolint:ll + localSig, remoteSig, closeOpts, err = muSession.CombineClosingOpts( //nolint:lll *matchingSig.PartialSig, *closeSignedMsg.PartialSig, ) diff --git a/lnwallet/chancloser/chancloser_test.go b/lnwallet/chancloser/chancloser_test.go index 61e62a1297..e6c2b773d5 100644 --- a/lnwallet/chancloser/chancloser_test.go +++ b/lnwallet/chancloser/chancloser_test.go @@ -211,7 +211,9 @@ func (m *mockChannel) FundingTxOut() *wire.TxOut { return nil } -func (m *mockChannel) MultiSigKeys() (keychain.KeyDescriptor, keychain.KeyDescriptor) { +func (m *mockChannel) MultiSigKeys() ( + keychain.KeyDescriptor, keychain.KeyDescriptor) { + return m.localKey, m.remoteKey } @@ -250,7 +252,9 @@ func newMockMusigSession() *mockMusigSession { return &mockMusigSession{} } -func (m *mockMusigSession) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt, error) { +func (m *mockMusigSession) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt, + error) { + return nil, nil } @@ -267,7 +271,6 @@ func (m *mockMusigSession) ClosingNonce() (*musig2.Nonces, error) { } func (m *mockMusigSession) InitRemoteNonce(nonce *musig2.Nonces) { - return } type mockCoopFeeEstimator struct { @@ -565,7 +568,7 @@ func TestTaprootFastClose(t *testing.T) { ogOffer := bobOffer.FeeSatoshis bobOffer.FeeSatoshis /= 2 - aliceMsgs, _, err = aliceCloser.ProcessCloseMsg(bobOffer) + _, _, err = aliceCloser.ProcessCloseMsg(bobOffer) require.Error(t, err) require.Contains(t, err.Error(), "was not accepted") diff --git a/lnwallet/chancloser/interface.go b/lnwallet/chancloser/interface.go index 33ba8b93b4..9d588d521a 100644 --- a/lnwallet/chancloser/interface.go +++ b/lnwallet/chancloser/interface.go @@ -27,7 +27,7 @@ type CoopFeeEstimator interface { // Channel abstracts away from the core channel state machine by exposing an // interface that requires only the methods we need to carry out the channel // closing process. -type Channel interface { +type Channel interface { //nolint:interfacebloat // ChannelPoint returns the channel point of the target channel. ChannelPoint() *wire.OutPoint @@ -70,10 +70,11 @@ type Channel interface { // CreateCloseProposal creates a new co-op close proposal in the form // of a valid signature, the chainhash of the final txid, and our final // balance in the created state. - CreateCloseProposal(proposedFee btcutil.Amount, localDeliveryScript []byte, - remoteDeliveryScript []byte, - closeOpt ...lnwallet.ChanCloseOpt) (input.Signature, *chainhash.Hash, - btcutil.Amount, error) + CreateCloseProposal(proposedFee btcutil.Amount, + localDeliveryScript []byte, remoteDeliveryScript []byte, + closeOpt ...lnwallet.ChanCloseOpt, + ) ( + input.Signature, *chainhash.Hash, btcutil.Amount, error) // CompleteCooperativeClose persistently "completes" the cooperative // close by producing a fully signed co-op close transaction. diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 3ca8e3ee4d..4fa9d1b659 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1402,7 +1402,7 @@ func NewLightningChannel(signer input.Signer, state.RevocationProducer, ) if err != nil { - return nil, fmt.Errorf("unable to derive shachain: %v", err) + return nil, fmt.Errorf("unable to derive shachain: %w", err) } lc := &LightningChannel{ @@ -1474,7 +1474,8 @@ func (lc *LightningChannel) createSignDesc() error { } } else { multiSigScript, err = input.GenMultiSigScript( - localKey.SerializeCompressed(), remoteKey.SerializeCompressed(), + localKey.SerializeCompressed(), + remoteKey.SerializeCompressed(), ) if err != nil { return err @@ -3365,7 +3366,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, // If this is a taproot channel, then we'll need to set the // method type to ensure we generate a valid signature. if chanType.IsTaproot() { - sigJob.SignDesc.SignMethod = input.TaprootScriptSpendSignMethod + sigJob.SignDesc.SignMethod = input.TaprootScriptSpendSignMethod //nolint:lll } sigBatch = append(sigBatch, sigJob) @@ -3433,7 +3434,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, // If this is a taproot channel, then we'll need to set the // method type to ensure we generate a valid signature. if chanType.IsTaproot() { - sigJob.SignDesc.SignMethod = input.TaprootScriptSpendSignMethod + sigJob.SignDesc.SignMethod = input.TaprootScriptSpendSignMethod //nolint:lll } sigBatch = append(sigBatch, sigJob) @@ -3879,7 +3880,6 @@ type NewCommitState struct { // HTLC's on the commitment transaction. Finally, the new set of pending HTLCs // for the remote party's commitment are also returned. func (lc *LightningChannel) SignNextCommitment() (*NewCommitState, error) { - lc.Lock() defer lc.Unlock() @@ -4572,8 +4572,9 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, htlcAmt := int64(htlc.Amount.ToSatoshis()) if chanType.IsTaproot() { - // TODO(roasbeef): add abstraction in front - prevFetcher := txscript.NewCannedPrevOutputFetcher( + // TODO(roasbeef): add abstraction in + // front + prevFetcher := txscript.NewCannedPrevOutputFetcher( //nolint:lll htlc.ourPkScript, htlcAmt, ) hashCache := txscript.NewTxSigHashes( @@ -4582,9 +4583,11 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, tapLeaf := txscript.NewBaseTapLeaf( htlc.ourWitnessScript, ) - return txscript.CalcTapscriptSignaturehash( - hashCache, sigHashType, successTx, 0, - prevFetcher, tapLeaf, + + return txscript.CalcTapscriptSignaturehash( //nolint:lll + hashCache, sigHashType, + successTx, 0, prevFetcher, + tapLeaf, ) } @@ -4643,8 +4646,9 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, timeoutTx, err := CreateHtlcTimeoutTx( chanType, isLocalInitiator, op, outputAmt, htlc.Timeout, - uint32(localChanCfg.CsvDelay), leaseExpiry, - keyRing.RevocationKey, keyRing.ToLocalKey, + uint32(localChanCfg.CsvDelay), + leaseExpiry, keyRing.RevocationKey, + keyRing.ToLocalKey, ) if err != nil { return nil, err @@ -4653,8 +4657,9 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, htlcAmt := int64(htlc.Amount.ToSatoshis()) if chanType.IsTaproot() { - // TODO(roasbeef): add abstraction in front - prevFetcher := txscript.NewCannedPrevOutputFetcher( + // TODO(roasbeef): add abstraction in + // front + prevFetcher := txscript.NewCannedPrevOutputFetcher( //nolint:lll htlc.ourPkScript, htlcAmt, ) hashCache := txscript.NewTxSigHashes( @@ -4663,13 +4668,17 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, tapLeaf := txscript.NewBaseTapLeaf( htlc.ourWitnessScript, ) - return txscript.CalcTapscriptSignaturehash( - hashCache, sigHashType, timeoutTx, 0, - prevFetcher, tapLeaf, + + return txscript.CalcTapscriptSignaturehash( //nolint:lll + hashCache, sigHashType, + timeoutTx, 0, prevFetcher, + tapLeaf, ) } - hashCache := input.NewTxSigHashesV0Only(timeoutTx) + hashCache := input.NewTxSigHashesV0Only( + timeoutTx, + ) sigHash, err := txscript.CalcWitnessSigHash( htlc.ourWitnessScript, hashCache, sigHashType, timeoutTx, 0, @@ -4809,8 +4818,9 @@ var _ error = (*InvalidCommitSigError)(nil) // to our local commitment chain. Once we send a revocation for our prior // state, then this newly added commitment becomes our current accepted channel // state. +// +//nolint:funlen func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { - lc.Lock() defer lc.Unlock() @@ -4936,7 +4946,7 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { // exact signature and commitment we failed to // verify against in order to aide debugging. var txBytes bytes.Buffer - localCommitTx.Serialize(&txBytes) + _ = localCommitTx.Serialize(&txBytes) return &InvalidPartialCommitSigError{ invalidPartialSigError: &sigErr, InvalidCommitSigError: InvalidCommitSigError{ //nolint:lll @@ -4959,7 +4969,6 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { return err } lc.musigSessions.LocalSession = newLocalSession - } else { multiSigScript := lc.signDesc.WitnessScript prevFetcher := txscript.NewCannedPrevOutputFetcher( @@ -4972,8 +4981,8 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { localCommitTx, 0, int64(lc.channelState.Capacity), ) if err != nil { - // TODO(roasbeef): fetchview has already mutated the HTLCs... - // * need to either roll-back, or make pure + // TODO(roasbeef): fetchview has already mutated the + // HTLCs... * need to either roll-back, or make pure return err } @@ -4992,10 +5001,11 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { // commitment we failed to verify against in order to // aide debugging. var txBytes bytes.Buffer - localCommitTx.Serialize(&txBytes) + _ = localCommitTx.Serialize(&txBytes) + return &InvalidCommitSigError{ commitHeight: nextHeight, - commitSig: commitSigs.CommitSig.ToSignatureBytes(), + commitSig: commitSigs.CommitSig.ToSignatureBytes(), //nolint:lll sigHash: sigHash, commitTx: txBytes.Bytes(), } @@ -5047,7 +5057,7 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error { localCommitmentView.sig = sigBytes[:] } else { - localCommitmentView.sig = commitSigs.CommitSig.ToSignatureBytes() + localCommitmentView.sig = commitSigs.CommitSig.ToSignatureBytes() //nolint:lll } lc.localCommitChain.addCommitment(localCommitmentView) @@ -7284,7 +7294,6 @@ func (lc *LightningChannel) CompleteCooperativeClose( finalSchnorrSig.Serialize(), } } else { - // For regular channels, we'll need to , construct the witness // stack minding the order of the pubkeys+sigs on the stack. ourKey := lc.channelState.LocalChanCfg.MultiSigKey.PubKey. @@ -7296,7 +7305,6 @@ func (lc *LightningChannel) CompleteCooperativeClose( remoteSig, ) closeTx.TxIn[0].Witness = witness - } // Validate the finalized transaction to ensure the output script is @@ -8261,7 +8269,9 @@ func (lc *LightningChannel) FundingTxOut() *wire.TxOut { } // MultiSigKeys returns the set of multi-sig keys for an channel. -func (lc *LightningChannel) MultiSigKeys() (keychain.KeyDescriptor, keychain.KeyDescriptor) { +func (lc *LightningChannel) MultiSigKeys() (keychain.KeyDescriptor, + keychain.KeyDescriptor) { + lc.RLock() defer lc.RUnlock() diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index 142ff57d02..276b378bcc 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -61,7 +61,8 @@ func assertOutputExistsByValue(t *testing.T, commitTx *wire.MsgTx, // testAddSettleWorkflow tests a simple channel scenario where Alice and Bob // add, the settle an HTLC between themselves. func testAddSettleWorkflow(t *testing.T, tweakless bool, - chanTypeModifier channeldb.ChannelType, storeFinalHtlcResolutions bool) { + chanTypeModifier channeldb.ChannelType, + storeFinalHtlcResolutions bool) { // Create a test channel which will be used for the duration of this // unittest. The channel will be funded evenly with Alice having 5 BTC, @@ -196,23 +197,26 @@ func testAddSettleWorkflow(t *testing.T, tweakless bool, aliceChannel.currentHeight, 1) } + aliceChanState := aliceChannel.channelState + bobChanState := bobChannel.channelState + // Both commitment transactions should have three outputs, and one of // them should be exactly the amount of the HTLC. numOutputs := 3 if chanTypeModifier.HasAnchors() { - // In this case we expect two extra outputs as both sides need an - // anchor output. + // In this case we expect two extra outputs as both sides need + // an anchor output. numOutputs = 5 } - if len(aliceChannel.channelState.LocalCommitment.CommitTx.TxOut) != numOutputs { + if len(aliceChanState.LocalCommitment.CommitTx.TxOut) != numOutputs { t.Fatalf("alice should have three commitment outputs, instead "+ "have %v", - len(aliceChannel.channelState.LocalCommitment.CommitTx.TxOut)) + len(aliceChanState.LocalCommitment.CommitTx.TxOut)) } - if len(bobChannel.channelState.LocalCommitment.CommitTx.TxOut) != numOutputs { + if len(bobChanState.LocalCommitment.CommitTx.TxOut) != numOutputs { t.Fatalf("bob should have three commitment outputs, instead "+ "have %v", - len(bobChannel.channelState.LocalCommitment.CommitTx.TxOut)) + len(bobChanState.LocalCommitment.CommitTx.TxOut)) } assertOutputExistsByValue(t, aliceChannel.channelState.LocalCommitment.CommitTx, @@ -367,7 +371,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) { }) } - t.Run("anchors", func(t *testing.T) { + t.Run("anchors", func(t *testing.T) { //nolint:paralleltest testAddSettleWorkflow( t, true, channeldb.AnchorOutputsBit|channeldb.ZeroHtlcTxFeeBit, @@ -375,12 +379,13 @@ func TestSimpleAddSettleWorkflow(t *testing.T) { ) }) - t.Run("taproot", func(t *testing.T) { + t.Run("taproot", func(t *testing.T) { //nolint:paralleltest testAddSettleWorkflow( t, true, channeldb.SimpleTaprootFeatureBit, false, ) }) + //nolint:paralleltest t.Run("storeFinalHtlcResolutions=true", func(t *testing.T) { testAddSettleWorkflow(t, false, 0, true) }) @@ -3105,8 +3110,10 @@ func TestChanSyncOweCommitment(t *testing.T) { spew.Sdump(aliceMsgsToSend[4])) } if commitSigMsg.CommitSig != aliceNewCommit.CommitSig { - t.Fatalf("commit sig msgs don't match: expected %x got %x", - aliceNewCommit.CommitSig, commitSigMsg.CommitSig) + t.Fatalf("commit sig msgs don't match: expected "+ + "%x got %x", + aliceNewCommit.CommitSig, + commitSigMsg.CommitSig) } if len(commitSigMsg.HtlcSigs) != len(aliceNewCommit.HtlcSigs) { t.Fatalf("wrong number of htlc sigs: expected %v, got %v", @@ -3539,10 +3546,10 @@ func testChanSyncOweRevocation(t *testing.T, chanType channeldb.ChannelType) { func TestChanSyncOweRevocation(t *testing.T) { t.Parallel() - t.Run("tweakless", func(t *testing.T) { + t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest testChanSyncOweRevocation(t, channeldb.SingleFunderTweaklessBit) }) - t.Run("taproot", func(t *testing.T) { + t.Run("taproot", func(t *testing.T) { //nolint:paralleltest taprootBits := channeldb.SimpleTaprootFeatureBit | channeldb.AnchorOutputsBit | channeldb.ZeroHtlcTxFeeBit | @@ -3631,7 +3638,9 @@ func testChanSyncOweRevocationAndCommit(t *testing.T, assertBobSendsRevokeAndCommit := func() { t.Helper() - bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg(aliceSyncMsg) + bobMsgsToSend, _, _, err := bobChannel.ProcessChanSyncMsg( + aliceSyncMsg, + ) if err != nil { t.Fatalf("unable to process chan sync msg: %v", err) } @@ -3641,26 +3650,31 @@ func testChanSyncOweRevocationAndCommit(t *testing.T, } bobReRevoke, ok := bobMsgsToSend[0].(*lnwire.RevokeAndAck) if !ok { - t.Fatalf("expected bob to re-send revoke, instead sending: %v", - spew.Sdump(bobMsgsToSend[0])) + t.Fatalf("expected bob to re-send revoke, instead "+ + "sending: %v", spew.Sdump(bobMsgsToSend[0])) } if !reflect.DeepEqual(bobReRevoke, bobRevocation) { - t.Fatalf("revocation msgs don't match: expected %v, got %v", - bobRevocation, bobReRevoke) + t.Fatalf("revocation msgs don't match: expected %v, "+ + "got %v", bobRevocation, bobReRevoke) } bobReCommitSigMsg, ok := bobMsgsToSend[1].(*lnwire.CommitSig) if !ok { - t.Fatalf("expected bob to re-send commit sig, instead sending: %v", + t.Fatalf("expected bob to re-send commit sig, "+ + "instead sending: %v", spew.Sdump(bobMsgsToSend[1])) } if bobReCommitSigMsg.CommitSig != bobNewCommit.CommitSig { - t.Fatalf("commit sig msgs don't match: expected %x got %x", + t.Fatalf("commit sig msgs don't match: expected %x "+ + "got %x", bobNewCommit.CommitSigs.CommitSig, bobReCommitSigMsg.CommitSig) } - if len(bobReCommitSigMsg.HtlcSigs) != len(bobNewCommit.HtlcSigs) { - t.Fatalf("wrong number of htlc sigs: expected %v, got %v", + if len(bobReCommitSigMsg.HtlcSigs) != + len(bobNewCommit.HtlcSigs) { + + t.Fatalf("wrong number of htlc sigs: expected %v, "+ + "got %v", len(bobNewCommit.HtlcSigs), len(bobReCommitSigMsg.HtlcSigs)) } @@ -3715,12 +3729,12 @@ func testChanSyncOweRevocationAndCommit(t *testing.T, func TestChanSyncOweRevocationAndCommit(t *testing.T) { t.Parallel() - t.Run("tweakless", func(t *testing.T) { + t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest testChanSyncOweRevocationAndCommit( t, channeldb.SingleFunderTweaklessBit, ) }) - t.Run("taproot", func(t *testing.T) { + t.Run("taproot", func(t *testing.T) { //nolint:paralleltest taprootBits := channeldb.SimpleTaprootFeatureBit | channeldb.AnchorOutputsBit | channeldb.ZeroHtlcTxFeeBit | @@ -3944,12 +3958,12 @@ func testChanSyncOweRevocationAndCommitForceTransition(t *testing.T, func TestChanSyncOweRevocationAndCommitForceTransition(t *testing.T) { t.Parallel() - t.Run("tweakless", func(t *testing.T) { + t.Run("tweakless", func(t *testing.T) { //nolint:paralleltest testChanSyncOweRevocationAndCommitForceTransition( t, channeldb.SingleFunderTweaklessBit, ) }) - t.Run("taproot", func(t *testing.T) { + t.Run("taproot", func(t *testing.T) { //nolint:paralleltest taprootBits := channeldb.SimpleTaprootFeatureBit | channeldb.AnchorOutputsBit | channeldb.ZeroHtlcTxFeeBit | diff --git a/lnwallet/test_utils.go b/lnwallet/test_utils.go index e4c7f2b31d..e33d563c3f 100644 --- a/lnwallet/test_utils.go +++ b/lnwallet/test_utils.go @@ -534,10 +534,12 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error { return err } - if _, _, _, _, err := chanA.ReceiveRevocation(bobRevocation); err != nil { + _, _, _, _, err = chanA.ReceiveRevocation(bobRevocation) + if err != nil { return err } - if err := chanA.ReceiveNewCommitment(bobNewCommit.CommitSigs); err != nil { + err = chanA.ReceiveNewCommitment(bobNewCommit.CommitSigs) + if err != nil { return err } @@ -545,7 +547,8 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error { if err != nil { return err } - if _, _, _, _, err := chanB.ReceiveRevocation(aliceRevocation); err != nil { + _, _, _, _, err = chanB.ReceiveRevocation(aliceRevocation) + if err != nil { return err } diff --git a/lnwallet/transactions.go b/lnwallet/transactions.go index 54ea1e7e4c..f66312a393 100644 --- a/lnwallet/transactions.go +++ b/lnwallet/transactions.go @@ -8,7 +8,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/input" ) const ( @@ -48,7 +47,7 @@ var ( // // In order to spend the segwit v1 (taproot) HTLC output, the witness for the // passed transaction should be: -// - +// - func CreateHtlcSuccessTx(chanType channeldb.ChannelType, initiator bool, htlcOutput wire.OutPoint, htlcAmt btcutil.Amount, csvDelay, leaseExpiry uint32, revocationKey, delayKey *btcec.PublicKey) ( @@ -136,36 +135,19 @@ func CreateHtlcTimeoutTx(chanType channeldb.ChannelType, initiator bool, var pkScript []byte - // Depending on if this is a taproot channel or not, we'll create a v0 - // vs v1 segwit script. - if chanType.IsTaproot() { - taprootOutputKey, err := input.TaprootSecondLevelHtlcScript( - revocationKey, delayKey, csvDelay, - ) - if err != nil { - return nil, err - } - - pkScript, err = input.PayToTaprootScript(taprootOutputKey) - if err != nil { - return nil, err - } - - } else { - // Next, we'll generate the script used as the output for all second - // level HTLC which forces a covenant w.r.t what can be done with all - // HTLC outputs. - scriptInfo, err := SecondLevelHtlcScript( - chanType, initiator, revocationKey, delayKey, csvDelay, - leaseExpiry, - ) - if err != nil { - return nil, err - } - - pkScript = scriptInfo.PkScript + // Next, we'll generate the script used as the output for all second + // level HTLC which forces a covenant w.r.t what can be done with all + // HTLC outputs. + scriptInfo, err := SecondLevelHtlcScript( + chanType, initiator, revocationKey, delayKey, csvDelay, + leaseExpiry, + ) + if err != nil { + return nil, err } + pkScript = scriptInfo.PkScript + // Finally, the output is simply the amount of the HTLC (minus the // required fees), paying to the regular second level HTLC script. timeoutTx.AddTxOut(&wire.TxOut{ diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index 677b0a9e32..a51eb726f0 100644 --- a/lnwallet/transactions_test.go +++ b/lnwallet/transactions_test.go @@ -300,10 +300,18 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) { remoteNewCommit, err := remoteChannel.SignNextCommitment() require.NoError(t, err) - require.Equal(t, test.RemoteSigHex, hex.EncodeToString(remoteNewCommit.CommitSig.ToSignatureBytes())) + require.Equal( + t, test.RemoteSigHex, + hex.EncodeToString( + remoteNewCommit.CommitSig.ToSignatureBytes(), + ), + ) for i, sig := range remoteNewCommit.HtlcSigs { - require.Equal(t, test.HtlcDescs[i].RemoteSigHex, hex.EncodeToString(sig.ToSignatureBytes())) + require.Equal( + t, test.HtlcDescs[i].RemoteSigHex, + hex.EncodeToString(sig.ToSignatureBytes()), + ) } err = localChannel.ReceiveNewCommitment(remoteNewCommit.CommitSigs) @@ -321,7 +329,10 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) { var txBytes bytes.Buffer require.NoError(t, forceCloseSum.CloseTx.Serialize(&txBytes)) - require.Equal(t, test.ExpectedCommitmentTxHex, hex.EncodeToString(txBytes.Bytes())) + require.Equal( + t, test.ExpectedCommitmentTxHex, + hex.EncodeToString(txBytes.Bytes()), + ) // Obtain the second level transactions that the local node's channel // state machine has produced. Store them in a map indexed by commit tx diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index 534c8dbb3f..33e3e250a7 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -2388,7 +2388,6 @@ func (l *LightningWallet) ValidateChannel(channelState *channeldb.OpenChannel, if err != nil { return err } - } else { witnessScript, err := input.GenMultiSigScript( localKey.SerializeCompressed(), diff --git a/peer/musig_chan_closer.go b/peer/musig_chan_closer.go index 22330cfd7b..3e9b654978 100644 --- a/peer/musig_chan_closer.go +++ b/peer/musig_chan_closer.go @@ -31,7 +31,9 @@ func NewMusigChanCloser(channel *lnwallet.LightningChannel) *MusigChanCloser { // ProposalClosingOpts returns the options that should be used when // generating a new co-op close signature. -func (m *MusigChanCloser) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt, error) { +func (m *MusigChanCloser) ProposalClosingOpts() ( + []lnwallet.ChanCloseOpt, error) { + switch { case m.localNonce == nil: return nil, fmt.Errorf("local nonce not generated")