lnwallet/chancloser: address lint and PR review feedback
What changed, and why it matters
This commit is a follow-up cleanup patch for a larger feature adding RBF (Replace-By-Fee) cooperative channel closes for Taproot channels in LND. It contains no direct security fixes. The changes are almost entirely code-style fixes (line length, blank lines, spelling, import ordering), test-only refactors, and minor defensive tweaks such as adding checked type assertions and removing a nonce cache that could be a 'footgun' in the future. The one substantive behavior change—removing the nonce cache—is described by the author as preventing future mistakes rather than fixing an active vulnerability.
No urgent action required. Treat as normal code-quality follow-up. If reviewing the parent RBF coop-close feature, verify that the removed nonce cache does not leave any race or stale-nonce path unhandled, and confirm that env.IsTaproot() correctly gates all Taproot-specific logic.
Security signals we found
Removal of a nonce cache described as a future footgun, not an active vulnerability
Checked type assertions added in test mocks to avoid panic on bad casts
Channel-type validation consolidated behind env.IsTaproot()
No changes to signature verification logic or wire parsing rules
Evidence from the diff
The diff is a lint/review cleanup on top of the Taproot RBF cooperative close work. It touches tests and wire message encoding in lnwallet/chancloser and lnwire. Notable non-cosmetic items: (1) removal of the ClosingNonce() nonce cache to avoid future footguns; (2) replacement of unchecked type assertions with checked ones in tests; (3) renaming of helper functions and replacing env.RemoteMusigSession != nil with env.IsTaproot() for channel-type checks; (4) removal of an unused remoteSchnorrSig test variable. There are no changes to consensus rules, cryptographic verification, or network message parsing that would obviously create or fix an exploitable bug. The commit message explicitly frames the nonce-cache removal as a future-proofing measure, not a security fix.
Changed components
lnwallet/chancloser/rbf_coop_transitions.golnwallet/chancloser/rbf_coop_test.golnwire/closing_complete.golnwire/closing_sig.golnwire/test_message.gopeer/musig_nonce_order_test.goitest/lnd_coop_close_rbf_test.goInspect captured patch +346 / −201
diff --git a/itest/lnd_coop_close_rbf_test.go b/itest/lnd_coop_close_rbf_test.go
index e4af6ea..f1acf02 100644
--- a/itest/lnd_coop_close_rbf_test.go
+++ b/itest/lnd_coop_close_rbf_test.go
@@ -14,8 +14,10 @@ import (
"github.com/stretchr/testify/require"
)
-// rbfTestCase encapsulates the parameters and logic for a single RBF coop close test run.
-func runRbfCoopCloseTest(st *lntest.HarnessTest, alice, bob *node.HarnessNode,
+// runRbfCoopCloseTest encapsulates the parameters and logic for a
+// single RBF coop close test run.
+func runRbfCoopCloseTest(st *lntest.HarnessTest,
+ alice, bob *node.HarnessNode,
chanPoint *lnrpc.ChannelPoint, isTaproot bool) {
// To start, we'll have Alice try to close the channel, with a fee rate
@@ -58,14 +60,22 @@ func runRbfCoopCloseTest(st *lntest.HarnessTest, alice, bob *node.HarnessNode,
alicePendingUpdate = aliceCloseUpdate.GetClosePending()
require.NotNil(st, aliceCloseUpdate)
- // For taproot channels, due to different witness sizes, the fee per vbyte
- // might be slightly different due to rounding when converting between
- // absolute fee and fee per vbyte.
+ // For taproot channels, due to different witness sizes,
+ // the fee per vbyte might be slightly different due to
+ // rounding when converting between absolute fee and fee
+ // per vbyte.
if isTaproot {
- // Allow for a small difference in fee calculation for taproot
- require.InDelta(st, int64(bobFeeRate), alicePendingUpdate.FeePerVbyte, 1)
+ // Allow for a small difference in fee
+ // calculation for taproot.
+ require.InDelta(
+ st, int64(bobFeeRate),
+ alicePendingUpdate.FeePerVbyte, 1,
+ )
} else {
- require.Equal(st, alicePendingUpdate.FeePerVbyte, int64(bobFeeRate))
+ require.Equal(
+ st, alicePendingUpdate.FeePerVbyte,
+ int64(bobFeeRate),
+ )
}
require.False(st, alicePendingUpdate.LocalCloseTx)
@@ -161,9 +171,10 @@ func testCoopCloseRbf(ht *lntest.HarnessTest) {
baseArgs := lntest.NodeArgsForCommitType(
chanType.commitType,
)
- nodeArgs := append(
+ baseArgs = append(
baseArgs, "--protocol.rbf-coop-close",
)
+ nodeArgs := baseArgs
cfgs := [][]string{nodeArgs, nodeArgs}
// For taproot channels, we need to make them private.
@@ -185,7 +196,9 @@ func testCoopCloseRbf(ht *lntest.HarnessTest) {
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
- runRbfCoopCloseTest(st, alice, bob, chanPoint, isTaproot)
+ runRbfCoopCloseTest(
+ st, alice, bob, chanPoint, isTaproot,
+ )
st.Shutdown(alice)
st.Shutdown(bob)
diff --git a/lnwallet/chancloser/rbf_coop_test.go b/lnwallet/chancloser/rbf_coop_test.go
index 512bd91..d14d0d2 100644
--- a/lnwallet/chancloser/rbf_coop_test.go
+++ b/lnwallet/chancloser/rbf_coop_test.go
@@ -60,11 +60,6 @@ var (
localSchnorrSigBytes,
)
- remoteSchnorrSigBytes = bytes.Repeat([]byte{0x02}, 64)
- remoteSchnorrSig, _ = lnwire.NewSigFromSchnorrRawSignature(
- remoteSchnorrSigBytes,
- )
-
localTx = wire.MsgTx{Version: 2}
closeTx = wire.NewMsgTx(2)
@@ -160,7 +155,7 @@ func assertUnknownEventFail(t *testing.T, startingState ProtocolState) {
defer closeHarness.stopAndAssert()
closeHarness.sendEventAndExpectFailure(
- context.Background(), &unknownEvent{},
+ t.Context(), &unknownEvent{},
ErrInvalidStateTransition,
)
})
@@ -180,7 +175,7 @@ func assertSpendEventCloseFin(t *testing.T, startingState ProtocolState) {
defer closeHarness.stopAndAssert()
closeHarness.chanCloser.SendEvent(
- context.Background(), &SpendEvent{},
+ t.Context(), &SpendEvent{},
)
closeHarness.assertStateTransitions(&CloseFin{})
@@ -441,7 +436,7 @@ func (r *rbfCloserTestHarness) expectNewCloseSig(
r.T.Helper()
- // For taproot channels, we'll return a musig2 partial siganture instead
+ // For taproot channels, we'll return a musig2 partial signature instead
// of the normal schnorr sig.
switch {
case r.env.LocalMusigSession != nil:
@@ -927,7 +922,7 @@ func TestSelectTaprootPartialSigWithNonce(t *testing.T) {
require.Equal(t, nonceNoClosee, selected.Nonce)
sigsNoCloser := lnwire.TaprootClosingSigs{
- NoCloserClosee: newPartialSigWithNonceTlv[tlv.TlvType6](noCloserPS),
+ NoCloserClosee: newPartialSigWithNonceTlv[tlv.TlvType6](noCloserPS), //nolint:ll
}
selected, err = selectTaprootPartialSigWithNonce(sigsNoCloser, false)
@@ -948,7 +943,7 @@ func assertStateT[T ProtocolState](h *rbfCloserTestHarness) T {
func newRbfCloserTestHarness(t *testing.T,
cfg *harnessCfg) *rbfCloserTestHarness {
- ctx := context.Background()
+ ctx := t.Context()
startingHeight := 200
@@ -1369,7 +1364,7 @@ func testRemoteInitiatedCloseOkTaproot(t *testing.T, ctx context.Context) {
// TestRbfChannelActiveTransitions tests the transitions of from the
// ChannelActive state.
func TestRbfChannelActiveTransitions(t *testing.T) {
- ctx := context.Background()
+ ctx := t.Context()
localAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x01}, 20))
remoteAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x02}, 20))
@@ -1519,7 +1514,7 @@ func TestRbfChannelActiveTransitions(t *testing.T) {
// shutdown ourselves.
func TestRbfShutdownPendingTransitions(t *testing.T) {
t.Parallel()
- ctx := context.Background()
+ ctx := t.Context()
startingState := &ShutdownPending{}
@@ -1573,7 +1568,7 @@ func TestRbfShutdownPendingTransitions(t *testing.T) {
// If the remote party sends a shutdown for a taproot channel without
// a nonce in the ShutdownPending state, we should reject it.
- t.Run("initiator_shutdown_recv_taproot_no_nonce_fail", func(t *testing.T) {
+ t.Run("initiator_shutdown_recv_taproot_no_nonce_fail", func(t *testing.T) { //nolint:ll
firstState := *startingState
firstState.IdealFeeRate = fn.Some(
chainfee.FeePerKwFloor.FeePerVByte(),
@@ -1760,7 +1755,7 @@ func TestRbfShutdownPendingTransitions(t *testing.T) {
// transition to the negotiation state.
func TestRbfChannelFlushingTransitions(t *testing.T) {
t.Parallel()
- ctx := context.Background()
+ ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(10_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
@@ -2002,7 +1997,8 @@ func testSendOfferRbfIterationLoopTaproot(t *testing.T,
lnwire.Musig2Nonce{4, 5, 6},
),
}
- localState := firstState.PeerState.Local.(*LocalCloseStart) //nolint:ll
+ localState, ok := firstState.PeerState.Local.(*LocalCloseStart)
+ require.True(t, ok)
localState.CloseChannelTerms.NonceState =
firstState.CloseChannelTerms.NonceState
@@ -2140,10 +2136,12 @@ func testRecvOfferRbfLoopIterationsTaproot(t *testing.T,
}
firstState.CloseChannelTerms.NonceState = nonceState
- localState := firstState.PeerState.Local.(*LocalCloseStart) //nolint:ll
+ localState, ok := firstState.PeerState.Local.(*LocalCloseStart)
+ require.True(t, ok)
localState.CloseChannelTerms.NonceState = nonceState
- remoteState := firstState.PeerState.Remote.(*RemoteCloseStart) //nolint:ll
+ remoteState, ok := firstState.PeerState.Remote.(*RemoteCloseStart) //nolint:ll
+ require.True(t, ok)
remoteState.CloseChannelTerms.NonceState = nonceState
cfg := &harnessCfg{
@@ -2165,22 +2163,25 @@ func testRecvOfferRbfLoopIterationsTaproot(t *testing.T,
balanceAfterClose := closingTerms.ShutdownBalances.RemoteBalance.ToSatoshis() - absoluteFee //nolint:ll
sequence := uint32(mempool.MaxRBFSequence)
+ closingSigs := lnwire.TaprootClosingSigs{
+ CloserAndClosee: newPartialSigWithNonceTlv[tlv.TlvType7]( //nolint:ll
+ lnwire.PartialSigWithNonce{
+ PartialSig: lnwire.PartialSig{
+ Sig: btcec.ModNScalar{},
+ },
+ Nonce: lnwire.Musig2Nonce{
+ 10, 11, 12,
+ },
+ },
+ ),
+ }
feeOffer := &OfferReceivedEvent{
SigMsg: lnwire.ClosingComplete{
- CloserScript: remoteAddr,
- CloseeScript: localAddr,
- FeeSatoshis: absoluteFee,
- LockTime: 1,
- TaprootClosingSigs: lnwire.TaprootClosingSigs{
- CloserAndClosee: newPartialSigWithNonceTlv[tlv.TlvType7]( //nolint:ll
- lnwire.PartialSigWithNonce{
- PartialSig: lnwire.PartialSig{
- Sig: btcec.ModNScalar{},
- },
- Nonce: lnwire.Musig2Nonce{10, 11, 12},
- },
- ),
- },
+ CloserScript: remoteAddr,
+ CloseeScript: localAddr,
+ FeeSatoshis: absoluteFee,
+ LockTime: 1,
+ TaprootClosingSigs: closingSigs,
},
}
@@ -2248,7 +2249,8 @@ func testSendOfferIterationNoDustTaproot(t *testing.T,
),
}
- localState := testStartingState.PeerState.Local.(*LocalCloseStart) //nolint:ll
+ localState, ok := testStartingState.PeerState.Local.(*LocalCloseStart) //nolint:ll
+ require.True(t, ok)
localState.CloseChannelTerms.NonceState =
testStartingState.CloseChannelTerms.NonceState
@@ -2293,7 +2295,7 @@ func testSendOfferIterationNoDustTaproot(t *testing.T,
// rate.
func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
t.Parallel()
- ctx := context.Background()
+ ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(40_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
@@ -2582,23 +2584,31 @@ func TestValidateSigTypeMatchesChannelType(t *testing.T) {
// Create a message with mismatched signature type
var sigMsg lnwire.ClosingSig
if tc.sendTaproot {
- // Send taproot signature using TaprootPartialSigs
- // Create a dummy partial sig
+ // Send taproot signature using
+ // TaprootPartialSigs. Create a
+ // dummy partial sig.
var scalar btcec.ModNScalar
scalar.SetByteSlice(localSchnorrSigBytes[:32])
partialSig := lnwire.PartialSig{Sig: scalar}
- sigMsg.TaprootPartialSigs.CloserAndClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType7](partialSig),
+ sigMsg.TaprootPartialSigs.CloserAndClosee = tlv.SomeRecordT( //nolint:ll
+ tlv.NewRecordT[tlv.TlvType7](
+ partialSig,
+ ),
)
testNonce := lnwire.Musig2Nonce{7, 8, 9}
- sigMsg.NextCloseeNonce = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType22](testNonce),
+ sigMsg.NextCloseeNonce = tlv.SomeRecordT( //nolint:ll
+ tlv.NewRecordT[tlv.TlvType22](
+ testNonce,
+ ),
)
} else {
- sigMsg.ClosingSigs.CloserAndClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType3](localSigWire),
+ sigs := &sigMsg.ClosingSigs
+ sigs.CloserAndClosee = tlv.SomeRecordT(
+ tlv.NewRecordT[tlv.TlvType3](
+ localSigWire,
+ ),
)
}
@@ -2609,7 +2619,9 @@ func TestValidateSigTypeMatchesChannelType(t *testing.T) {
if tc.expectedError != "" {
_, err := sigResult.Unpack()
require.Error(t, err)
- require.Contains(t, err.Error(), tc.expectedError)
+ require.Contains(
+ t, err.Error(), tc.expectedError,
+ )
} else {
sig, err := sigResult.Unpack()
require.NoError(t, err)
@@ -2629,7 +2641,7 @@ func TestValidateSigTypeMatchesChannelType(t *testing.T) {
func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
t.Parallel()
- ctx := context.Background()
+ ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(40_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
@@ -3053,7 +3065,7 @@ func TestTaprootNonceHandling(t *testing.T) {
// Send the shutdown event and verify state transition. We should
// transition to ShutdownPending.
closeHarness.chanCloser.SendEvent(
- context.Background(), shutdownEvent,
+ t.Context(), shutdownEvent,
)
closeHarness.assertStateTransitions(&ShutdownPending{})
@@ -3158,7 +3170,7 @@ func TestProcessRemoteTaprootSigWithSignerNonce(t *testing.T) {
jitNonce := lnwire.Musig2Nonce{20, 21, 22}
msg := lnwire.ClosingComplete{
TaprootClosingSigs: lnwire.TaprootClosingSigs{
- CloserAndClosee: newPartialSigWithNonceTlv[tlv.TlvType7](
+ CloserAndClosee: newPartialSigWithNonceTlv[tlv.TlvType7]( //nolint:ll
lnwire.PartialSigWithNonce{
PartialSig: lnwire.PartialSig{
Sig: btcec.ModNScalar{},
@@ -3203,9 +3215,8 @@ func newStrictNonceMusigSession() *strictNonceMusigSession {
return &strictNonceMusigSession{}
}
-func (m *strictNonceMusigSession) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt,
- error) {
-
+//nolint:ll
+func (m *strictNonceMusigSession) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt, error) {
// Track if ProposalClosingOpts was called before InitRemoteNonce.
if !m.remoteNonceInited {
m.proposalOptsCalledBeforeInit = true
@@ -3258,8 +3269,10 @@ func TestLocalOfferSentUsesStoredSig(t *testing.T) {
RemoteDeliveryScript: remoteAddr,
},
NonceState: NonceState{
- LocalCloseeNonce: fn.Some(lnwire.Musig2Nonce{1, 2, 3}),
- RemoteCloseeNonce: fn.Some(remoteCloseeNonceFromShutdown),
+ LocalCloseeNonce: fn.Some(lnwire.Musig2Nonce{1, 2, 3}),
+ RemoteCloseeNonce: fn.Some(
+ remoteCloseeNonceFromShutdown,
+ ),
},
ShutdownBalances: ShutdownBalances{
LocalBalance: lnwire.NewMSatFromSatoshis(500_000),
diff --git a/lnwallet/chancloser/rbf_coop_transitions.go b/lnwallet/chancloser/rbf_coop_transitions.go
index 9c3788d..9ca47ed 100644
--- a/lnwallet/chancloser/rbf_coop_transitions.go
+++ b/lnwallet/chancloser/rbf_coop_transitions.go
@@ -30,11 +30,12 @@ var (
ErrThawHeightNotReached = fmt.Errorf("thaw height not reached")
)
-// sendShutdownEvents is a helper function that returns a set of daemon events
-// we need to emit when we decide that we should send a shutdown message. We'll
-// also mark the channel as borked as well, as at this point, we no longer want
-// to continue with normal operation. This function also returns the actual closee
-// nonce used (either provided or auto-generated) for taproot channels.
+// sendShutdownEvents is a helper function that returns a set of daemon
+// events we need to emit when we decide that we should send a shutdown
+// message. We'll also mark the channel as borked as well, as at this
+// point, we no longer want to continue with normal operation. This
+// function also returns the actual closee nonce used (either provided
+// or auto-generated) for taproot channels.
func sendShutdownEvents(chanID lnwire.ChannelID, chanPoint wire.OutPoint,
deliveryAddr lnwire.DeliveryAddress, peerPub btcec.PublicKey,
postSendEvent fn.Option[ProtocolEvent], chanState ChanStateObserver,
@@ -100,7 +101,8 @@ func sendShutdownEvents(chanID lnwire.ChannelID, chanPoint wire.OutPoint,
// If a close is already in process (we're in the RBF loop), then we
// can skip everything below, and just send out the shutdown message.
if chanState.FinalBalances().IsSome() {
- return protofsm.DaemonEventSet{msgsToSend}, localCloseeNonce, nil
+ return protofsm.DaemonEventSet{msgsToSend},
+ localCloseeNonce, nil
}
// Before closing, we'll attempt to send a disable update for the
@@ -163,7 +165,9 @@ func initRemoteMusigCloserNonce(env *Environment,
if env.RemoteMusigSession != nil {
remoteCloserNonce.WhenSome(func(nonce lnwire.Musig2Nonce) {
remoteMusigNonce := musig2.Nonces{PubNonce: nonce}
- env.RemoteMusigSession.InitRemoteNonce(&remoteMusigNonce)
+ env.RemoteMusigSession.InitRemoteNonce(
+ &remoteMusigNonce,
+ )
})
}
}
@@ -347,7 +351,7 @@ func (c *ChannelActive) ProcessEvent(event ProtocolEvent, env *Environment,
RemoteDeliveryScript: remoteAddr,
},
NonceState: NonceState{
- RemoteCloseeNonce: msg.RemoteShutdownNonce,
+ RemoteCloseeNonce: msg.RemoteShutdownNonce, //nolint:ll
LocalCloseeNonce: closeeNonce,
},
},
@@ -713,13 +717,15 @@ func partialSigToWireSig(partialSig lnwire.PartialSig) lnwire.Sig {
sigBytes := partialSig.Sig.Bytes()
copy(wireSig.RawBytes()[:32], sigBytes[:])
wireSig.ForceSchnorr()
+
return wireSig
}
// extractTaprootSigAndNonce extracts the partial signature and closee nonce
// from a taproot ClosingSig message.
-func extractTaprootSigAndNonce(msg lnwire.ClosingSig) (sig fn.Result[lnwire.Sig],
- nonce fn.Option[lnwire.Musig2Nonce]) {
+func extractTaprootSigAndNonce(
+ msg lnwire.ClosingSig) (fn.Result[lnwire.Sig],
+ fn.Option[lnwire.Musig2Nonce]) {
// Count how many taproot sig fields are populated.
taprootSigInts := []bool{
@@ -727,17 +733,23 @@ func extractTaprootSigAndNonce(msg lnwire.ClosingSig) (sig fn.Result[lnwire.Sig]
msg.TaprootPartialSigs.NoCloserClosee.IsSome(),
msg.TaprootPartialSigs.CloserAndClosee.IsSome(),
}
- numTaprootSigs := fn.Foldl(0, taprootSigInts, func(acc int, sigInt bool) int { //nolint:ll
- if sigInt {
- return acc + 1
- }
- return acc
- })
+ numTaprootSigs := fn.Foldl(
+ 0, taprootSigInts,
+ func(acc int, sigInt bool) int {
+ if sigInt {
+ return acc + 1
+ }
+
+ return acc
+ },
+ )
// Validate exactly one sig is set.
if numTaprootSigs != 1 {
- return fn.Errf[lnwire.Sig]("%w: only one sig should be set, got %v",
- ErrTooManySigs, numTaprootSigs), fn.None[lnwire.Musig2Nonce]()
+ return fn.Errf[lnwire.Sig](
+ "%w: only one sig should be set, got %v",
+ ErrTooManySigs, numTaprootSigs,
+ ), fn.None[lnwire.Musig2Nonce]()
}
tapSigs := msg.TaprootPartialSigs
@@ -786,14 +798,16 @@ func extractRegularSig(msg lnwire.ClosingSig) fn.Result[lnwire.Sig] {
msg.ClosingSigs.NoCloserClosee.IsSome(),
msg.ClosingSigs.CloserAndClosee.IsSome(),
}
- numRegularSigs := fn.Foldl(0, regularSigInts, func(acc int,
- sigInt bool) int {
+ numRegularSigs := fn.Foldl(
+ 0, regularSigInts,
+ func(acc int, sigInt bool) int {
+ if sigInt {
+ return acc + 1
+ }
- if sigInt {
- return acc + 1
- }
- return acc
- })
+ return acc
+ },
+ )
// Validate exactly one sig is set
if numRegularSigs != 1 {
@@ -805,23 +819,32 @@ func extractRegularSig(msg lnwire.ClosingSig) fn.Result[lnwire.Sig] {
switch {
case msg.ClosingSigs.CloserNoClosee.IsSome():
var sig lnwire.Sig
- msg.ClosingSigs.CloserNoClosee.WhenSomeV(func(s lnwire.Sig) {
- sig = s
- })
+ msg.ClosingSigs.CloserNoClosee.WhenSomeV(
+ func(s lnwire.Sig) {
+ sig = s
+ },
+ )
+
return fn.Ok(sig)
case msg.ClosingSigs.NoCloserClosee.IsSome():
var sig lnwire.Sig
- msg.ClosingSigs.NoCloserClosee.WhenSomeV(func(s lnwire.Sig) {
- sig = s
- })
+ msg.ClosingSigs.NoCloserClosee.WhenSomeV(
+ func(s lnwire.Sig) {
+ sig = s
+ },
+ )
+
return fn.Ok(sig)
case msg.ClosingSigs.CloserAndClosee.IsSome():
var sig lnwire.Sig
- msg.ClosingSigs.CloserAndClosee.WhenSomeV(func(s lnwire.Sig) {
- sig = s
- })
+ msg.ClosingSigs.CloserAndClosee.WhenSomeV(
+ func(s lnwire.Sig) {
+ sig = s
+ },
+ )
+
return fn.Ok(sig)
default:
@@ -833,8 +856,9 @@ func extractRegularSig(msg lnwire.ClosingSig) fn.Result[lnwire.Sig] {
// ClosingSig message matches the channel type (taproot vs non-taproot), then
// extracts the partial signature and the NextCloseeNonce for the next RBF
// round. This is used by the closer when receiving the closee's response.
-func extractSigAndNonceFromClosingSig(msg lnwire.ClosingSig,
-) (sig fn.Result[lnwire.Sig], nonce fn.Option[lnwire.Musig2Nonce]) {
+func extractSigAndNonceFromClosingSig(
+ msg lnwire.ClosingSig,
+) (fn.Result[lnwire.Sig], fn.Option[lnwire.Musig2Nonce]) {
// Check if this is a taproot or regular signature.
hasTaprootSigs := msg.TaprootPartialSigs.CloserNoClosee.IsSome() ||
@@ -861,8 +885,9 @@ func extractSigAndNonceFromClosingSig(msg lnwire.ClosingSig,
// validateAndExtractSigAndNonce validates that the signature type matches the
// channel type and then extracts the signature and nonce.
-func validateAndExtractSigAndNonce(msg lnwire.ClosingSig,
- isTaproot bool) (sig fn.Result[lnwire.Sig], nonce fn.Option[lnwire.Musig2Nonce]) {
+func validateAndExtractSigAndNonce(
+ msg lnwire.ClosingSig, isTaproot bool,
+) (fn.Result[lnwire.Sig], fn.Option[lnwire.Musig2Nonce]) {
// Check if this is a taproot or regular signature.
hasTaprootSigs := msg.TaprootPartialSigs.CloserNoClosee.IsSome() ||
@@ -1055,28 +1080,35 @@ func encodeClosingSignatures(env *Environment, wireSig lnwire.Sig,
}
// Convert the musig partial sig to wire format.
- // This already includes our JIT closer nonce that we used to sign.
+ // This already includes our JIT closer nonce that we
+ // used to sign.
partialSigWithNonce := musigPartialSig.ToWireSig()
switch {
case noCloser:
taprootClosingSigs.NoCloserClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType6](*partialSigWithNonce),
+ tlv.NewRecordT[tlv.TlvType6](
+ *partialSigWithNonce,
+ ),
)
case noClosee:
taprootClosingSigs.CloserNoClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType5](*partialSigWithNonce),
+ tlv.NewRecordT[tlv.TlvType5](
+ *partialSigWithNonce,
+ ),
)
default:
taprootClosingSigs.CloserAndClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType7](*partialSigWithNonce),
+ tlv.NewRecordT[tlv.TlvType7](
+ *partialSigWithNonce,
+ ),
)
}
return closingSigs, taprootClosingSigs, nil
}
- // For non-taproot channels, we'll populate the normal ECDSA sigantures.
+ // For non-taproot channels, we'll populate the normal ECDSA signatures.
switch {
case noClosee:
closingSigs.CloserNoClosee = newSigTlv[tlv.TlvType1](wireSig)
@@ -1292,25 +1324,31 @@ func selectTaprootPartialSigWithNonce(
return ps, ErrCloserNoClosee
}
- sigs.CloserNoClosee.WhenSomeV(func(p lnwire.PartialSigWithNonce) {
- ps = p
- })
+ sigs.CloserNoClosee.WhenSomeV(
+ func(p lnwire.PartialSigWithNonce) {
+ ps = p
+ },
+ )
return ps, nil
}
if sigs.CloserAndClosee.IsSome() {
- sigs.CloserAndClosee.WhenSomeV(func(p lnwire.PartialSigWithNonce) {
- ps = p
- })
+ sigs.CloserAndClosee.WhenSomeV(
+ func(p lnwire.PartialSigWithNonce) {
+ ps = p
+ },
+ )
return ps, nil
}
if sigs.NoCloserClosee.IsSome() {
- sigs.NoCloserClosee.WhenSomeV(func(p lnwire.PartialSigWithNonce) {
- ps = p
- })
+ sigs.NoCloserClosee.WhenSomeV(
+ func(p lnwire.PartialSigWithNonce) {
+ ps = p
+ },
+ )
return ps, nil
}
@@ -1395,32 +1433,43 @@ func createClosingSigMessage(env *Environment, wireSig lnwire.Sig,
}, nil
}
-// extractTaprootPartialSig extracts just the PartialSig from TaprootPartialSigs.
-// This is useful when we need the actual partial sig for combining.
-func extractTaprootPartialSig(sigs lnwire.TaprootPartialSigs) (
- partialSig fn.Option[lnwire.PartialSig]) {
+// extractTaprootPartialSig extracts just the PartialSig from
+// TaprootPartialSigs. This is useful when we need the actual
+// partial sig for combining.
+func extractTaprootPartialSig(
+ sigs lnwire.TaprootPartialSigs,
+) fn.Option[lnwire.PartialSig] {
if sigs.CloserNoClosee.IsSome() {
var ps lnwire.PartialSig
- sigs.CloserNoClosee.WhenSomeV(func(p lnwire.PartialSig) {
- ps = p
- })
+ sigs.CloserNoClosee.WhenSomeV(
+ func(p lnwire.PartialSig) {
+ ps = p
+ },
+ )
+
return fn.Some(ps)
}
if sigs.NoCloserClosee.IsSome() {
var ps lnwire.PartialSig
- sigs.NoCloserClosee.WhenSomeV(func(p lnwire.PartialSig) {
- ps = p
- })
+ sigs.NoCloserClosee.WhenSomeV(
+ func(p lnwire.PartialSig) {
+ ps = p
+ },
+ )
+
return fn.Some(ps)
}
if sigs.CloserAndClosee.IsSome() {
var ps lnwire.PartialSig
- sigs.CloserAndClosee.WhenSomeV(func(p lnwire.PartialSig) {
- ps = p
- })
+ sigs.CloserAndClosee.WhenSomeV(
+ func(p lnwire.PartialSig) {
+ ps = p
+ },
+ )
+
return fn.Some(ps)
}
@@ -1431,11 +1480,12 @@ func extractTaprootPartialSig(sigs lnwire.TaprootPartialSigs) (
// closing transaction. For taproot channels, it handles musig signature
// combination. For non-taproot channels, it converts wire signatures to regular
// signatures.
-func prepareClosingSignatures(env *Environment, l *LocalOfferSent,
- msg *LocalSigReceived, sig lnwire.Sig,
+func prepareClosingSignatures(env *Environment,
+ l *LocalOfferSent, msg *LocalSigReceived,
+ sig lnwire.Sig,
closeOpts []lnwallet.ChanCloseOpt,
-) (localSig, remoteSig input.Signature,
- musigOpts []lnwallet.ChanCloseOpt, err error) {
+) (input.Signature, input.Signature,
+ []lnwallet.ChanCloseOpt, error) {
if env.IsTaproot() {
// Use the stored MusigPartialSig from LocalCloseStart rather
@@ -1480,11 +1530,11 @@ func prepareClosingSignatures(env *Environment, l *LocalOfferSent,
// For non-taproot channels, convert wire signatures to regular
// signatures.
- remoteSig, err = sig.ToSignature()
+ remoteSig, err := sig.ToSignature()
if err != nil {
return nil, nil, nil, err
}
- localSig, err = l.LocalSig.ToSignature()
+ localSig, err := l.LocalSig.ToSignature()
if err != nil {
return nil, nil, nil, err
}
@@ -1822,14 +1872,20 @@ func validateSigFields(sigFields SigFieldSet, localIsDust bool) error {
// selectAndExtractSig selects the appropriate signature field based on BOLT
// spec priority and extracts the signature and nonce.
-func selectAndExtractSig(fields SigFieldSet, localIsDust bool) (
- sig lnwire.Sig, nonce fn.Option[lnwire.Musig2Nonce], isNoClosee bool,
- err error) {
+func selectAndExtractSig(
+ fields SigFieldSet, localIsDust bool,
+) (lnwire.Sig, fn.Option[lnwire.Musig2Nonce], bool,
+ error) {
// Select which field to use based on BOLT spec priority.
- var selectedField fn.Option[SigType]
+ var (
+ selectedField fn.Option[SigType]
+ isNoClosee bool
+ )
+
if localIsDust {
- // Spec step 1: Local output is dust, use CloserNoClosee.
+ // Spec step 1: Local output is dust, use
+ // CloserNoClosee.
selectedField = fields.CloserNoClosee
isNoClosee = true
} else {
@@ -1847,19 +1903,22 @@ func selectAndExtractSig(fields SigFieldSet, localIsDust bool) (
// If the selected field is none, this is an error.
sigType, err := selectedField.UnwrapOrErr(ErrNoSig)
if err != nil {
- return lnwire.Sig{}, fn.None[lnwire.Musig2Nonce](), false, err
+ return lnwire.Sig{}, fn.None[lnwire.Musig2Nonce](),
+ false, err
}
- // Check if this is a taproot signature (Right side of Either) or
- // regular (Left side).
- nonce = fn.None[lnwire.Musig2Nonce]()
+ // Check if this is a taproot signature (Right side of
+ // Either) or regular (Left side).
+ var sig lnwire.Sig
+ nonce := fn.None[lnwire.Musig2Nonce]()
// If this is a regular signature, extract it directly.
sigType.WhenLeft(func(regularSig lnwire.Sig) {
sig = regularSig
})
- // Otherwise, for taproot, extract the partial sig and nonce.
+ // Otherwise, for taproot, extract the partial sig and
+ // nonce.
sigType.WhenRight(func(ps lnwire.PartialSigWithNonce) {
nonce = fn.Some(ps.Nonce)
sig = partialSigToWireSig(ps.PartialSig)
@@ -1868,14 +1927,17 @@ func selectAndExtractSig(fields SigFieldSet, localIsDust bool) (
return sig, nonce, isNoClosee, nil
}
-// extractSigAndNonceFromClosingComplete extracts signature and optional nonce
-// from ClosingComplete using a three-phase approach: parse, validate, and select.
+// extractSigAndNonceFromClosingComplete extracts signature and optional
+// nonce from ClosingComplete using a three-phase approach: parse,
+// validate, and select.
//
// This function implements the BOLT spec requirements for the receiver (closee)
// of a closing_complete message.
-func extractSigAndNonceFromClosingComplete(msg lnwire.ClosingComplete,
- localIsDust, isTaproot bool) (sig lnwire.Sig,
- nonce fn.Option[lnwire.Musig2Nonce], isNoClosee bool, err error) {
+func extractSigAndNonceFromClosingComplete(
+ msg lnwire.ClosingComplete,
+ localIsDust, isTaproot bool,
+) (lnwire.Sig, fn.Option[lnwire.Musig2Nonce], bool,
+ error) {
// First, parse the message to extract which signature fields are
// present.
@@ -1902,11 +1964,14 @@ func extractSigAndNonceFromClosingComplete(msg lnwire.ClosingComplete,
return lnwire.Sig{}, fn.None[lnwire.Musig2Nonce](), false, err
}
- // Finally, select and extract the appropriate signature based on BOLT
- // spec priority.
- sig, nonce, isNoClosee, err = selectAndExtractSig(fields, localIsDust)
+ // Finally, select and extract the appropriate signature
+ // based on BOLT spec priority.
+ sig, nonce, isNoClosee, err := selectAndExtractSig(
+ fields, localIsDust,
+ )
if err != nil {
- return lnwire.Sig{}, fn.None[lnwire.Musig2Nonce](), false, err
+ return lnwire.Sig{}, fn.None[lnwire.Musig2Nonce](),
+ false, err
}
return sig, nonce, isNoClosee, nil
@@ -1937,7 +2002,7 @@ func (l *RemoteCloseStart) ProcessEvent(event ProtocolEvent, env *Environment,
// Extract the signature and JIT nonce from the ClosingComplete
// message. This function parses, validates, and selects the
// appropriate signature per BOLT spec.
- sig, jitNonce, noClosee, err := extractSigAndNonceFromClosingComplete(
+ sig, jitNonce, noClosee, err := extractSigAndNonceFromClosingComplete( //nolint:ll
msg.SigMsg, l.LocalAmtIsDust(), env.IsTaproot(),
)
if err != nil {
@@ -1970,7 +2035,8 @@ func (l *RemoteCloseStart) ProcessEvent(event ProtocolEvent, env *Environment,
// Now that the nonce is initialized, get the musig
// closing options.
- musigOpts, err := env.RemoteMusigSession.ProposalClosingOpts()
+ session := env.RemoteMusigSession
+ musigOpts, err := session.ProposalClosingOpts()
if err != nil {
return nil, fmt.Errorf("failed to get musig "+
"closing opts: %w", err)
diff --git a/lnwire/closing_complete.go b/lnwire/closing_complete.go
index 88fead2..c062689 100644
--- a/lnwire/closing_complete.go
+++ b/lnwire/closing_complete.go
@@ -72,8 +72,8 @@ type ClosingComplete struct {
// can be sent. Each signature includes the nonce for the next RBF
// round (implementing the JIT nonce pattern).
//
- // NOTE: This field is only populated for taproot channels. When present,
- // the above ClosingSigs MUST be empty.
+ // NOTE: This field is only populated for taproot channels. When
+ // present, the above ClosingSigs MUST be empty.
TaprootClosingSigs
// ExtraData is the set of data that was appended to this message to
@@ -84,7 +84,9 @@ type ClosingComplete struct {
// decodeClosingSigs decodes the closing sig TLV records in the passed
// ExtraOpaqueData.
-func decodeClosingSigs(c *ClosingSigs, tc *TaprootClosingSigs, tlvRecords ExtraOpaqueData) error {
+func decodeClosingSigs(c *ClosingSigs,
+ tc *TaprootClosingSigs,
+ tlvRecords ExtraOpaqueData) error {
// Regular signatures
sig1 := c.CloserNoClosee.Zero()
sig2 := c.NoCloserClosee.Zero()
@@ -155,7 +157,11 @@ func (c *ClosingComplete) Decode(r io.Reader, _ uint32) error {
return err
}
- if err := decodeClosingSigs(&c.ClosingSigs, &c.TaprootClosingSigs, tlvRecords); err != nil {
+ err = decodeClosingSigs(
+ &c.ClosingSigs, &c.TaprootClosingSigs,
+ tlvRecords,
+ )
+ if err != nil {
return err
}
@@ -168,7 +174,10 @@ func (c *ClosingComplete) Decode(r io.Reader, _ uint32) error {
// closingSigRecords returns the set of records that encode the closing sigs,
// including both regular and taproot signatures.
-func closingSigRecords(c *ClosingSigs, tc *TaprootClosingSigs) []tlv.RecordProducer {
+func closingSigRecords(c *ClosingSigs,
+ tc *TaprootClosingSigs,
+) []tlv.RecordProducer {
+
recordProducers := make([]tlv.RecordProducer, 0, 6)
// Regular signatures
@@ -182,16 +191,22 @@ func closingSigRecords(c *ClosingSigs, tc *TaprootClosingSigs) []tlv.RecordProdu
recordProducers = append(recordProducers, &sig)
})
- // Taproot signatures (with nonces)
- tc.CloserNoClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType5, PartialSigWithNonce]) {
- recordProducers = append(recordProducers, &sig)
- })
- tc.NoCloserClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType6, PartialSigWithNonce]) {
- recordProducers = append(recordProducers, &sig)
- })
- tc.CloserAndClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType7, PartialSigWithNonce]) {
- recordProducers = append(recordProducers, &sig)
- })
+ // Taproot signatures (with nonces).
+ tc.CloserNoClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType5, PartialSigWithNonce]) {
+ recordProducers = append(recordProducers, &sig)
+ },
+ )
+ tc.NoCloserClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType6, PartialSigWithNonce]) {
+ recordProducers = append(recordProducers, &sig)
+ },
+ )
+ tc.CloserAndClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType7, PartialSigWithNonce]) {
+ recordProducers = append(recordProducers, &sig)
+ },
+ )
return recordProducers
}
@@ -217,7 +232,9 @@ func (c *ClosingComplete) Encode(w *bytes.Buffer, _ uint32) error {
return err
}
- recordProducers := closingSigRecords(&c.ClosingSigs, &c.TaprootClosingSigs)
+ recordProducers := closingSigRecords(
+ &c.ClosingSigs, &c.TaprootClosingSigs,
+ )
err := EncodeMessageExtraData(&c.ExtraData, recordProducers...)
if err != nil {
diff --git a/lnwire/closing_sig.go b/lnwire/closing_sig.go
index a14dcb8..919a329 100644
--- a/lnwire/closing_sig.go
+++ b/lnwire/closing_sig.go
@@ -9,7 +9,8 @@ import (
"github.com/lightningnetwork/lnd/tlv"
)
-// TaprootPartialSigs houses the 3 possible taproot partial signatures (without nonces)
+// TaprootPartialSigs houses the 3 possible taproot partial
+// signatures (without nonces)
// that can be sent in a ClosingSig message. These use just PartialSig since the
// receiver already knows our nonce from the previous ClosingComplete.
type TaprootPartialSigs struct {
@@ -57,8 +58,8 @@ type ClosingSig struct {
// without the nonce since the remote already knows our nonce from the
// previous ClosingComplete message.
//
- // NOTE: This field is only populated for taproot channels. When present,
- // the above ClosingSigs MUST be empty.
+ // NOTE: This field is only populated for taproot channels. When
+ // present, the above ClosingSigs MUST be empty.
TaprootPartialSigs
// NextCloseeNonce is an optional nonce for RBF iterations. This is the
@@ -159,7 +160,11 @@ func (c *ClosingSig) Decode(r io.Reader, _ uint32) error {
return err
}
- if err := decodeClosingSigSigs(&c.ClosingSigs, &c.TaprootPartialSigs, &c.NextCloseeNonce, tlvRecords); err != nil {
+ err = decodeClosingSigSigs(
+ &c.ClosingSigs, &c.TaprootPartialSigs,
+ &c.NextCloseeNonce, tlvRecords,
+ )
+ if err != nil {
return err
}
@@ -172,8 +177,11 @@ func (c *ClosingSig) Decode(r io.Reader, _ uint32) error {
// closingSigSigRecords returns the set of records that encode the closing sigs,
// including both regular and taproot signatures.
-func closingSigSigRecords(c *ClosingSigs, tp *TaprootPartialSigs,
- nextNonce tlv.OptionalRecordT[tlv.TlvType22, Musig2Nonce]) []tlv.RecordProducer {
+func closingSigSigRecords(c *ClosingSigs,
+ tp *TaprootPartialSigs,
+ nextNonce tlv.OptionalRecordT[tlv.TlvType22, Musig2Nonce],
+) []tlv.RecordProducer {
+
recordProducers := make([]tlv.RecordProducer, 0, 7)
// Regular signatures
@@ -187,16 +195,28 @@ func closingSigSigRecords(c *ClosingSigs, tp *TaprootPartialSigs,
recordProducers = append(recordProducers, &sig)
})
- // Taproot partial signatures (without nonces)
- tp.CloserNoClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType5, PartialSig]) {
- recordProducers = append(recordProducers, &sig)
- })
- tp.NoCloserClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType6, PartialSig]) {
- recordProducers = append(recordProducers, &sig)
- })
- tp.CloserAndClosee.WhenSome(func(sig tlv.RecordT[tlv.TlvType7, PartialSig]) {
- recordProducers = append(recordProducers, &sig)
- })
+ // Taproot partial signatures (without nonces).
+ tp.CloserNoClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType5, PartialSig]) {
+ recordProducers = append(
+ recordProducers, &sig,
+ )
+ },
+ )
+ tp.NoCloserClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType6, PartialSig]) {
+ recordProducers = append(
+ recordProducers, &sig,
+ )
+ },
+ )
+ tp.CloserAndClosee.WhenSome(
+ func(sig tlv.RecordT[tlv.TlvType7, PartialSig]) {
+ recordProducers = append(
+ recordProducers, &sig,
+ )
+ },
+ )
// Next closee nonce for RBF
nextNonce.WhenSome(func(nonce tlv.RecordT[tlv.TlvType22, Musig2Nonce]) {
@@ -227,7 +247,10 @@ func (c *ClosingSig) Encode(w *bytes.Buffer, _ uint32) error {
return err
}
- recordProducers := closingSigSigRecords(&c.ClosingSigs, &c.TaprootPartialSigs, c.NextCloseeNonce)
+ recordProducers := closingSigSigRecords(
+ &c.ClosingSigs, &c.TaprootPartialSigs,
+ c.NextCloseeNonce,
+ )
err := EncodeMessageExtraData(&c.ExtraData, recordProducers...)
if err != nil {
diff --git a/lnwire/test_message.go b/lnwire/test_message.go
index 9b3ebbc..17f67f9 100644
--- a/lnwire/test_message.go
+++ b/lnwire/test_message.go
@@ -670,7 +670,7 @@ func (c *ClosingComplete) RandTestMessage(t *rapid.T) Message {
partialSig := *RandPartialSig(t)
nonce := RandMusig2Nonce(t)
msg.TaprootClosingSigs.CloserNoClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType5, PartialSigWithNonce](
+ tlv.NewRecordT[tlv.TlvType5, PartialSigWithNonce]( //nolint:ll
PartialSigWithNonce{
PartialSig: partialSig,
Nonce: nonce,
@@ -683,7 +683,7 @@ func (c *ClosingComplete) RandTestMessage(t *rapid.T) Message {
partialSig := *RandPartialSig(t)
nonce := RandMusig2Nonce(t)
msg.TaprootClosingSigs.NoCloserClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType6, PartialSigWithNonce](
+ tlv.NewRecordT[tlv.TlvType6, PartialSigWithNonce]( //nolint:ll
PartialSigWithNonce{
PartialSig: partialSig,
Nonce: nonce,
@@ -695,8 +695,8 @@ func (c *ClosingComplete) RandTestMessage(t *rapid.T) Message {
if includeCloserAndClosee {
partialSig := *RandPartialSig(t)
nonce := RandMusig2Nonce(t)
- msg.TaprootClosingSigs.CloserAndClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType7, PartialSigWithNonce](
+ msg.TaprootClosingSigs.CloserAndClosee = tlv.SomeRecordT( //nolint:ll
+ tlv.NewRecordT[tlv.TlvType7, PartialSigWithNonce]( //nolint:ll
PartialSigWithNonce{
PartialSig: partialSig,
Nonce: nonce,
@@ -777,25 +777,26 @@ func (c *ClosingSig) RandTestMessage(t *rapid.T) Message {
useTaprootSigs := rapid.Bool().Draw(t, "useTaprootSigs")
if useTaprootSigs {
- // For taproot channels in ClosingSig, use just PartialSig (no nonce)
+ // For taproot channels in ClosingSig, use just PartialSig (no
+ // nonce).
if includeCloserNoClosee {
partialSig := *RandPartialSig(t)
msg.TaprootPartialSigs.CloserNoClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType5, PartialSig](partialSig),
+ tlv.NewRecordT[tlv.TlvType5, PartialSig](partialSig), //nolint:ll
)
}
if includeNoCloserClosee {
partialSig := *RandPartialSig(t)
msg.TaprootPartialSigs.NoCloserClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType6, PartialSig](partialSig),
+ tlv.NewRecordT[tlv.TlvType6, PartialSig](partialSig), //nolint:ll
)
}
if includeCloserAndClosee {
partialSig := *RandPartialSig(t)
- msg.TaprootPartialSigs.CloserAndClosee = tlv.SomeRecordT(
- tlv.NewRecordT[tlv.TlvType7, PartialSig](partialSig),
+ msg.TaprootPartialSigs.CloserAndClosee = tlv.SomeRecordT( //nolint:ll
+ tlv.NewRecordT[tlv.TlvType7, PartialSig](partialSig), //nolint:ll
)
}
} else {
diff --git a/peer/musig_nonce_order_test.go b/peer/musig_nonce_order_test.go
index 19f0ebd..1391864 100644
--- a/peer/musig_nonce_order_test.go
+++ b/peer/musig_nonce_order_test.go
@@ -38,7 +38,8 @@ func TestRemoteCloseStartTaprootIntegration(t *testing.T) {
require.NoError(t, err)
// Create TWO SEPARATE MusigChanCloser instances. This is the key to
- // exposing the bug - in production where the issue existed, they share one.
+ // exposing the bug - in production where the issue
+ // existed, they share one.
localSession := NewMusigChanCloser(aliceChan)
remoteSession := NewMusigChanCloser(bobChan)
@@ -217,8 +218,11 @@ func (m *mockCloseSigner) CreateCloseProposal(
args := m.Called(proposedFee, localDeliveryScript,
remoteDeliveryScript, closeOpt)
- return args.Get(0).(input.Signature), args.Get(1).(*wire.MsgTx),
- args.Get(2).(btcutil.Amount), args.Error(3)
+ sig, _ := args.Get(0).(input.Signature)
+ tx, _ := args.Get(1).(*wire.MsgTx)
+ amt, _ := args.Get(2).(btcutil.Amount)
+
+ return sig, tx, amt, args.Error(3)
}
func (m *mockCloseSigner) CompleteCooperativeClose(
@@ -230,8 +234,10 @@ func (m *mockCloseSigner) CompleteCooperativeClose(
args := m.Called(localSig, remoteSig, localDeliveryScript,
remoteDeliveryScript, proposedFee, closeOpts)
- return args.Get(0).(*wire.MsgTx), args.Get(1).(btcutil.Amount),
- args.Error(2)
+ tx, _ := args.Get(0).(*wire.MsgTx)
+ amt, _ := args.Get(1).(btcutil.Amount)
+
+ return tx, amt, args.Error(2)
}
type mockCoopFeeEstimator struct {
@@ -244,7 +250,9 @@ func (m *mockCoopFeeEstimator) EstimateFee(
args := m.Called(chanType, localTxOut, remoteTxOut, idealFeeRate)
- return args.Get(0).(btcutil.Amount)
+ amt, _ := args.Get(0).(btcutil.Amount)
+
+ return amt
}
type mockChanObserver struct {
@@ -291,8 +299,12 @@ func (m *mockChanObserver) MarkShutdownSent(deliveryAddr []byte,
return args.Error(0)
}
+//nolint:ll
func (m *mockChanObserver) FinalBalances() fn.Option[chancloser.ShutdownBalances] {
args := m.Called()
- return args.Get(0).(fn.Option[chancloser.ShutdownBalances])
+ //nolint:forcetypeassert
+ val := args.Get(0).(fn.Option[chancloser.ShutdownBalances])
+
+ return val
}
Why this scored 17/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.