What changed, and why it matters
This commit is purely a code cleanup patch titled 'fix linter issues'. It reformats long lines, adds whitespace, replaces if-else chains with switch statements, and adds linter suppression comments. There are no functional changes to how the software behaves, and nothing in the commit message or diff indicates a security fix.
No security action needed. Treat as normal maintenance/refactoring commit. Reviewers may optionally verify that the switch-statement conversions preserve the original precedence and that no //nolint directives hide real issues in future changes.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows only stylistic and lint-driven changes across 26 files. Examples include: breaking long function signatures and comments across multiple lines, converting if/else-if/else blocks to switch statements, adding //nolint:ll and //nolint:unconvert directives, and minor formatting adjustments in tests. No logic, constants, algorithms, or wire protocol behavior is altered. The watchtower TODO comments about final taproot scripts remain unchanged except for line wrapping.
Changed components
cmd/commands/cmd_open_channel.gocontractcourt/channel_arbitrator.gocontractcourt/htlc_incoming_contest_resolver.gocontractcourt/htlc_outgoing_contest_resolver.gocontractcourt/htlc_success_resolver.gocontractcourt/htlc_timeout_resolver.gofunding/commitment_type_negotiation_test.goinput/input.goinput/script_utils.goinput/size_test.goitest/lnd_channel_backup_test.goitest/lnd_funding_test.goitest/lnd_multi-hop_force_close_test.goitest/lnd_payment_test.goitest/lnd_psbt_test.goitest/lnd_remote_signer_test.golnwallet/channel_revoke_nonces_test.golnwallet/channel_test.golnwallet/commitment.golnwallet/musig_session.golnwallet/reservation.golnwallet/taproot_test_vectors_test.golnwire/revoke_and_ack.golnwire/test_message.gorpcserver.gowatchtower/blob/justice_kit.goInspect captured patch +445 / −292
diff --git a/cmd/commands/cmd_open_channel.go b/cmd/commands/cmd_open_channel.go
index 289d69b..7adf48a 100644
--- a/cmd/commands/cmd_open_channel.go
+++ b/cmd/commands/cmd_open_channel.go
@@ -59,9 +59,9 @@ Signed base64 encoded PSBT or hex encoded raw wire TX (or path to file): `
// of memory issues or other weird errors.
psbtMaxFileSize = 1024 * 1024
- channelTypeTweakless = "tweakless"
- channelTypeAnchors = "anchors"
- channelTypeSimpleTaproot = "taproot"
+ channelTypeTweakless = "tweakless"
+ channelTypeAnchors = "anchors"
+ channelTypeSimpleTaproot = "taproot"
channelTypeSimpleTaprootFinal = "taproot-final"
)
@@ -257,7 +257,8 @@ var openChannelCommand = cli.Command{
Usage: fmt.Sprintf("(optional) the type of channel to "+
"propose to the remote peer (%q, %q, %q, %q)",
channelTypeTweakless, channelTypeAnchors,
- channelTypeSimpleTaproot, channelTypeSimpleTaprootFinal),
+ channelTypeSimpleTaproot,
+ channelTypeSimpleTaprootFinal),
},
cli.BoolFlag{
Name: "zero_conf",
diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go
index a6ae4e6..a1b6f64 100644
--- a/contractcourt/channel_arbitrator.go
+++ b/contractcourt/channel_arbitrator.go
@@ -2469,7 +2469,8 @@ func (c *ChannelArbitrator) prepContractResolutions(
resolver := newSuccessResolver(
- resolution, height, htlc, chanType, resolverCfg,
+ resolution, height, htlc, chanType,
+ resolverCfg,
)
if chanState != nil {
resolver.SupplementState(chanState)
@@ -2499,7 +2500,8 @@ func (c *ChannelArbitrator) prepContractResolutions(
resolver := newTimeoutResolver(
- resolution, height, htlc, chanType, resolverCfg,
+ resolution, height, htlc, chanType,
+ resolverCfg,
)
if chanState != nil {
resolver.SupplementState(chanState)
@@ -2574,7 +2576,8 @@ func (c *ChannelArbitrator) prepContractResolutions(
resolver := newOutgoingContestResolver(
- resolution, height, htlc, chanType, resolverCfg,
+ resolution, height, htlc, chanType,
+ resolverCfg,
)
if chanState != nil {
resolver.SupplementState(chanState)
diff --git a/contractcourt/htlc_incoming_contest_resolver.go b/contractcourt/htlc_incoming_contest_resolver.go
index ad4747a..7034980 100644
--- a/contractcourt/htlc_incoming_contest_resolver.go
+++ b/contractcourt/htlc_incoming_contest_resolver.go
@@ -42,7 +42,8 @@ type htlcIncomingContestResolver struct {
// newIncomingContestResolver instantiates a new incoming htlc contest resolver.
func newIncomingContestResolver(
res lnwallet.IncomingHtlcResolution, broadcastHeight uint32,
- htlc channeldb.HTLC, chanType channeldb.ChannelType, resCfg ResolverConfig) *htlcIncomingContestResolver {
+ htlc channeldb.HTLC, chanType channeldb.ChannelType,
+ resCfg ResolverConfig) *htlcIncomingContestResolver {
success := newSuccessResolver(
res, broadcastHeight, htlc, chanType, resCfg,
diff --git a/contractcourt/htlc_outgoing_contest_resolver.go b/contractcourt/htlc_outgoing_contest_resolver.go
index 241117c..64db6bc 100644
--- a/contractcourt/htlc_outgoing_contest_resolver.go
+++ b/contractcourt/htlc_outgoing_contest_resolver.go
@@ -24,7 +24,8 @@ type htlcOutgoingContestResolver struct {
// resolver.
func newOutgoingContestResolver(res lnwallet.OutgoingHtlcResolution,
broadcastHeight uint32, htlc channeldb.HTLC,
- chanType channeldb.ChannelType, resCfg ResolverConfig) *htlcOutgoingContestResolver {
+ chanType channeldb.ChannelType,
+ resCfg ResolverConfig) *htlcOutgoingContestResolver {
timeout := newTimeoutResolver(
res, broadcastHeight, htlc, chanType, resCfg,
diff --git a/contractcourt/htlc_success_resolver.go b/contractcourt/htlc_success_resolver.go
index f692fbd..1770c21 100644
--- a/contractcourt/htlc_success_resolver.go
+++ b/contractcourt/htlc_success_resolver.go
@@ -70,7 +70,8 @@ type htlcSuccessResolver struct {
// newSuccessResolver instanties a new htlc success resolver.
func newSuccessResolver(res lnwallet.IncomingHtlcResolution,
broadcastHeight uint32, htlc channeldb.HTLC,
- chanType channeldb.ChannelType, resCfg ResolverConfig) *htlcSuccessResolver {
+ chanType channeldb.ChannelType,
+ resCfg ResolverConfig) *htlcSuccessResolver {
h := &htlcSuccessResolver{
contractResolverKit: *newContractResolverKit(resCfg),
@@ -424,7 +425,8 @@ func (h *htlcSuccessResolver) isTaproot() bool {
)
}
-// isTaprootFinal returns true if the htlc output is from a final taproot channel.
+// isTaprootFinal returns true if the htlc output is from a final taproot
+// channel.
func (h *htlcSuccessResolver) isTaprootFinal() bool {
return h.chanType.IsTaprootFinal()
}
@@ -437,7 +439,8 @@ func (h *htlcSuccessResolver) sweepRemoteCommitOutput() error {
// sweeping transaction, and generate a witness.
var inp input.Input
- if h.isTaprootFinal() {
+ switch {
+ case h.isTaprootFinal():
inp = lnutils.Ptr(input.MakeTaprootHtlcSucceedInputFinal(
&h.htlcResolution.ClaimOutpoint,
&h.htlcResolution.SweepSignDesc,
@@ -448,7 +451,7 @@ func (h *htlcSuccessResolver) sweepRemoteCommitOutput() error {
h.htlcResolution.ResolutionBlob,
),
))
- } else if h.isTaproot() {
+ case h.isTaproot():
inp = lnutils.Ptr(input.MakeTaprootHtlcSucceedInput(
&h.htlcResolution.ClaimOutpoint,
&h.htlcResolution.SweepSignDesc,
@@ -459,7 +462,7 @@ func (h *htlcSuccessResolver) sweepRemoteCommitOutput() error {
h.htlcResolution.ResolutionBlob,
),
))
- } else {
+ default:
inp = lnutils.Ptr(input.MakeHtlcSucceedInput(
&h.htlcResolution.ClaimOutpoint,
&h.htlcResolution.SweepSignDesc,
@@ -593,11 +596,12 @@ func (h *htlcSuccessResolver) sweepSuccessTxOutput() error {
// Let the sweeper sweep the second-level output now that the
// CSV/CLTV locks have expired.
var witType input.StandardWitnessType
- if h.isTaprootFinal() {
+ switch {
+ case h.isTaprootFinal():
witType = input.TaprootHtlcAcceptedSuccessSecondLevelFinal
- } else if h.isTaproot() {
+ case h.isTaproot():
witType = input.TaprootHtlcAcceptedSuccessSecondLevel
- } else {
+ default:
witType = input.HtlcAcceptedSuccessSecondLevel
}
inp := h.makeSweepInput(
diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go
index 0728e10..c2cbb13 100644
--- a/contractcourt/htlc_timeout_resolver.go
+++ b/contractcourt/htlc_timeout_resolver.go
@@ -72,7 +72,8 @@ type htlcTimeoutResolver struct {
// newTimeoutResolver instantiates a new timeout htlc resolver.
func newTimeoutResolver(res lnwallet.OutgoingHtlcResolution,
broadcastHeight uint32, htlc channeldb.HTLC,
- chanType channeldb.ChannelType, resCfg ResolverConfig) *htlcTimeoutResolver {
+ chanType channeldb.ChannelType,
+ resCfg ResolverConfig) *htlcTimeoutResolver {
h := &htlcTimeoutResolver{
contractResolverKit: *newContractResolverKit(resCfg),
@@ -95,7 +96,8 @@ func (h *htlcTimeoutResolver) isTaproot() bool {
)
}
-// isTaprootFinal returns true if the htlc output is from a final taproot channel.
+// isTaprootFinal returns true if the htlc output is from a final taproot
+// channel.
func (h *htlcTimeoutResolver) isTaprootFinal() bool {
return h.chanType.IsTaprootFinal()
}
@@ -524,11 +526,12 @@ func (h *htlcTimeoutResolver) resolveSecondLevelTxLegacy() error {
// are resolved via this path.
func (h *htlcTimeoutResolver) sweepDirectHtlcOutput() error {
var htlcWitnessType input.StandardWitnessType
- if h.isTaprootFinal() {
+ switch {
+ case h.isTaprootFinal():
htlcWitnessType = input.TaprootHtlcOfferedRemoteTimeoutFinal
- } else if h.isTaproot() {
+ case h.isTaproot():
htlcWitnessType = input.TaprootHtlcOfferedRemoteTimeout
- } else {
+ default:
htlcWitnessType = input.HtlcOfferedRemoteTimeout
}
@@ -1052,11 +1055,12 @@ func (h *htlcTimeoutResolver) sweepTimeoutTxOutput() error {
}
var witType input.StandardWitnessType
- if h.isTaprootFinal() {
+ switch {
+ case h.isTaprootFinal():
witType = input.TaprootHtlcOfferedTimeoutSecondLevelFinal
- } else if h.isTaproot() {
+ case h.isTaproot():
witType = input.TaprootHtlcOfferedTimeoutSecondLevel
- } else {
+ default:
witType = input.HtlcOfferedTimeoutSecondLevel
}
diff --git a/funding/commitment_type_negotiation_test.go b/funding/commitment_type_negotiation_test.go
index 4f7432f..5da4e05 100644
--- a/funding/commitment_type_negotiation_test.go
+++ b/funding/commitment_type_negotiation_test.go
@@ -308,7 +308,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
expectsErr: nil,
},
- // Test cases for final taproot channels with explicit negotiation.
+ // Test cases for final taproot channels with explicit
+ // negotiation.
{
name: "explicit simple taproot final only",
channelFeatures: lnwire.NewRawFeatureVector(
@@ -322,10 +323,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.SimpleTaprootChannelsOptionalFinal,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
),
),
expectsErr: nil,
@@ -346,10 +347,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.ScidAliasOptional,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
lnwire.ScidAliasRequired,
),
),
@@ -372,10 +373,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.ZeroConfOptional,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
lnwire.ZeroConfRequired,
),
),
@@ -383,7 +384,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
expectsErr: nil,
},
{
- name: "explicit simple taproot final with scid alias and zero conf",
+ name: "explicit simple taproot final with scid alias " +
+ "and zero conf",
channelFeatures: lnwire.NewRawFeatureVector(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ScidAliasRequired,
@@ -401,10 +403,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.ZeroConfOptional,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
lnwire.ScidAliasRequired,
lnwire.ZeroConfRequired,
),
@@ -414,7 +416,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
expectsErr: nil,
},
{
- name: "explicit simple taproot final missing remote support",
+ name: "explicit simple taproot final missing " +
+ "remote support",
channelFeatures: lnwire.NewRawFeatureVector(
lnwire.SimpleTaprootChannelsRequiredFinal,
),
@@ -429,9 +432,11 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
expectsErr: errUnsupportedChannelType,
},
- // Test cases for implicit negotiation preferring final over staging.
+ // Test cases for implicit negotiation preferring
+ // final over staging.
{
- name: "implicit final taproot preferred over staging",
+ name: "implicit final taproot preferred " +
+ "over staging",
channelFeatures: nil,
localFeatures: lnwire.NewRawFeatureVector(
lnwire.SimpleTaprootChannelsOptionalFinal,
@@ -443,16 +448,17 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.SimpleTaprootChannelsOptionalStaging,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
),
),
expectsErr: nil,
},
{
- name: "implicit staging taproot when final not supported",
+ name: "implicit staging taproot when final " +
+ "not supported",
channelFeatures: nil,
localFeatures: lnwire.NewRawFeatureVector(
lnwire.SimpleTaprootChannelsOptionalFinal,
@@ -466,7 +472,7 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
expectsCommitType: lnwallet.CommitmentTypeSimpleTaproot,
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredStaging,
+ lnwire.SimpleTaprootChannelsRequiredStaging, //nolint:ll
),
),
expectsErr: nil,
@@ -482,10 +488,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
lnwire.SimpleTaprootChannelsOptionalFinal,
lnwire.ExplicitChannelTypeOptional,
),
- expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal,
+ expectsCommitType: lnwallet.CommitmentTypeSimpleTaprootFinal, //nolint:ll
expectsChanType: (*lnwire.ChannelType)(
lnwire.NewRawFeatureVector(
- lnwire.SimpleTaprootChannelsRequiredFinal,
+ lnwire.SimpleTaprootChannelsRequiredFinal, //nolint:ll
),
),
expectsErr: nil,
diff --git a/input/input.go b/input/input.go
index 176efeb..5ca4271 100644
--- a/input/input.go
+++ b/input/input.go
@@ -339,12 +339,12 @@ func MakeTaprootHtlcSucceedInput(op *wire.OutPoint, signDesc *SignDescriptor,
}
}
-// MakeTaprootHtlcSucceedInputFinal creates a new HtlcSucceedInput that can be used
-// to spend an HTLC output for a production taproot channel on the remote party's
-// commitment transaction.
-func MakeTaprootHtlcSucceedInputFinal(op *wire.OutPoint, signDesc *SignDescriptor,
- preimage []byte, heightHint, blocksToMaturity uint32,
- opts ...InputOpt) HtlcSucceedInput {
+// MakeTaprootHtlcSucceedInputFinal creates a new HtlcSucceedInput that can be
+// used to spend an HTLC output for a production taproot channel on the remote
+// party's commitment transaction.
+func MakeTaprootHtlcSucceedInputFinal(op *wire.OutPoint,
+ signDesc *SignDescriptor, preimage []byte, heightHint,
+ blocksToMaturity uint32, opts ...InputOpt) HtlcSucceedInput {
input := MakeBaseInput(
op, TaprootHtlcAcceptedRemoteSuccessFinal, signDesc,
diff --git a/input/script_utils.go b/input/script_utils.go
index 192f589..3b907fc 100644
--- a/input/script_utils.go
+++ b/input/script_utils.go
@@ -1549,12 +1549,15 @@ func TaprootSecondLevelTapLeaf(delayKey *btcec.PublicKey,
// SecondLevelHtlcTapscriptTree construct the indexed tapscript tree needed to
// generate the tap tweak to create the final output and also control block.
-func SecondLevelHtlcTapscriptTree(delayKey *btcec.PublicKey, csvDelay uint32,
- auxLeaf AuxTapLeaf, opts ...TaprootScriptOpt) (*txscript.IndexedTapScriptTree, error) {
+func SecondLevelHtlcTapscriptTree(delayKey *btcec.PublicKey,
+ csvDelay uint32, auxLeaf AuxTapLeaf,
+ opts ...TaprootScriptOpt) (*txscript.IndexedTapScriptTree, error) {
// First grab the second level leaf script we need to create the top
// level output.
- secondLevelTapLeaf, err := TaprootSecondLevelTapLeaf(delayKey, csvDelay, opts...)
+ secondLevelTapLeaf, err := TaprootSecondLevelTapLeaf(
+ delayKey, csvDelay, opts...,
+ )
if err != nil {
return nil, err
}
@@ -1586,7 +1589,8 @@ func SecondLevelHtlcTapscriptTree(delayKey *btcec.PublicKey, csvDelay uint32,
//
// The keyspend path require knowledge of the top level revocation private key.
func TaprootSecondLevelHtlcScript(revokeKey, delayKey *btcec.PublicKey,
- csvDelay uint32, auxLeaf AuxTapLeaf, opts ...TaprootScriptOpt) (*btcec.PublicKey, error) {
+ csvDelay uint32, auxLeaf AuxTapLeaf,
+ opts ...TaprootScriptOpt) (*btcec.PublicKey, error) {
// First, we'll make the tapscript tree that commits to the redemption
// path.
@@ -1625,7 +1629,8 @@ type SecondLevelScriptTree struct {
// TaprootSecondLevelScriptTree constructs the tapscript tree used to spend the
// second level HTLC output.
func TaprootSecondLevelScriptTree(revokeKey, delayKey *btcec.PublicKey,
- csvDelay uint32, auxLeaf AuxTapLeaf, opts ...TaprootScriptOpt) (*SecondLevelScriptTree, error) {
+ csvDelay uint32, auxLeaf AuxTapLeaf,
+ opts ...TaprootScriptOpt) (*SecondLevelScriptTree, error) {
// First, we'll make the tapscript tree that commits to the redemption
// path.
diff --git a/input/size_test.go b/input/size_test.go
index 1d957c2..b089a83 100644
--- a/input/size_test.go
+++ b/input/size_test.go
@@ -1740,15 +1740,21 @@ func TestTaprootScriptOptions(t *testing.T) {
)
require.NoError(t, err)
- // For sender HTLC, only the success script (redeemed by receiver) differs.
+ // For sender HTLC, only the success script (redeemed
+ // by receiver) differs.
require.NotEqual(t, stagingScript.SuccessTapLeaf.Script,
prodScript.SuccessTapLeaf.Script,
- "staging and production sender success scripts should differ")
+ "staging and production sender success "+
+ "scripts should differ",
+ )
- // Production success script should be smaller due to OP_CHECKSIGVERIFY optimizations.
+ // Production success script should be smaller due to
+ // OP_CHECKSIGVERIFY optimizations.
require.Less(t, len(prodScript.SuccessTapLeaf.Script),
len(stagingScript.SuccessTapLeaf.Script),
- "production sender success script should be smaller than staging")
+ "production sender success script "+
+ "should be smaller than staging",
+ )
// Both should have valid tapscript trees.
require.NotNil(t, stagingScript.TapscriptTree)
@@ -1775,15 +1781,21 @@ func TestTaprootScriptOptions(t *testing.T) {
)
require.NoError(t, err)
- // For receiver HTLC, the timeout script (sender reclaims) should differ.
+ // For receiver HTLC, the timeout script (sender
+ // reclaims) should differ.
require.NotEqual(t, stagingScript.TimeoutTapLeaf.Script,
prodScript.TimeoutTapLeaf.Script,
- "staging and production receiver timeout scripts should differ")
+ "staging and production receiver "+
+ "timeout scripts should differ",
+ )
- // Production timeout script should be smaller due to OP_CHECKSIGVERIFY optimizations.
+ // Production timeout script should be smaller due to
+ // OP_CHECKSIGVERIFY optimizations.
require.Less(t, len(prodScript.TimeoutTapLeaf.Script),
len(stagingScript.TimeoutTapLeaf.Script),
- "production receiver timeout script should be smaller than staging")
+ "production receiver timeout script "+
+ "should be smaller than staging",
+ )
// Both should have valid tapscript trees.
require.NotNil(t, stagingScript.TapscriptTree)
@@ -1808,21 +1820,29 @@ func TestTaprootScriptOptions(t *testing.T) {
)
require.NoError(t, err)
- // Only the settle script should differ between staging and production.
- // The revocation script doesn't implement production optimizations.
+ // Only the settle script should differ between staging
+ // and production.
+ // The revocation script doesn't implement production
+ // optimizations.
require.NotEqual(t, stagingScript.SettleLeaf.Script,
prodScript.SettleLeaf.Script,
"staging and production settle scripts should differ")
- // Revocation scripts should be identical (no production optimization).
+ // Revocation scripts should be identical (no production
+ // optimization).
require.Equal(t, stagingScript.RevocationLeaf.Script,
prodScript.RevocationLeaf.Script,
- "revocation scripts should be identical between staging and production")
+ "revocation scripts should be identical "+
+ "between staging and "+
+ "production")
- // Production settle script should be smaller due to OP_CHECKSIGVERIFY optimizations.
+ // Production settle script should be smaller due to
+ // OP_CHECKSIGVERIFY optimizations.
require.Less(t, len(prodScript.SettleLeaf.Script),
len(stagingScript.SettleLeaf.Script),
- "production settle script should be smaller than staging")
+ "production settle script should "+
+ "be smaller than staging",
+ )
// Both should have valid tapscript trees.
require.NotNil(t, stagingScript.TapscriptTree)
diff --git a/itest/lnd_channel_backup_test.go b/itest/lnd_channel_backup_test.go
index f4911a9..b100fe5 100644
--- a/itest/lnd_channel_backup_test.go
+++ b/itest/lnd_channel_backup_test.go
@@ -195,6 +195,7 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
var privateChan bool
if ct == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
ct == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+
privateChan = true
}
@@ -642,6 +643,7 @@ func runChanRestoreScenarioCommitTypes(ht *lntest.HarnessTest,
// otherwise).
if (ct == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
ct == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL) && zeroConf {
+
ht.MineBlocksAndAssertNumTxes(1, 1)
}
diff --git a/itest/lnd_funding_test.go b/itest/lnd_funding_test.go
index 04f7798..bf36d7a 100644
--- a/itest/lnd_funding_test.go
+++ b/itest/lnd_funding_test.go
@@ -194,6 +194,7 @@ func runBasicFundingTest(ht *lntest.HarnessTest, carolCommitType,
// TODO(roasbeef): lift after gossip 1.75
if carolCommitType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
carolCommitType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+
privateChan = true
}
diff --git a/itest/lnd_multi-hop_force_close_test.go b/itest/lnd_multi-hop_force_close_test.go
index 7e87089..1e90129 100644
--- a/itest/lnd_multi-hop_force_close_test.go
+++ b/itest/lnd_multi-hop_force_close_test.go
@@ -365,7 +365,7 @@ func testLocalClaimOutgoingHTLCSimpleTaprootFinal(ht *lntest.HarnessTest) {
// testLocalClaimOutgoingHTLCSimpleTaprootFinalZeroConf tests
// `runLocalClaimOutgoingHTLC` with zero-conf production simple taproot channel.
-func testLocalClaimOutgoingHTLCSimpleTaprootFinalZeroConf(ht *lntest.HarnessTest) {
+func testLocalClaimOutgoingHTLCSimpleTaprootFinalZeroConf(ht *lntest.HarnessTest) { //nolint:ll
c := lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
// Create a three hop network: Alice -> Bob -> Carol, using zero-conf
@@ -464,8 +464,12 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -729,7 +733,7 @@ func testMultiHopReceiverPreimageClaimSimpleTaprootZeroConf(
// testMultiHopReceiverPreimageClaimSimpleTaprootFinal tests
// `runMultiHopReceiverPreimageClaim` with production simple taproot channels.
-func testMultiHopReceiverPreimageClaimSimpleTaprootFinal(ht *lntest.HarnessTest) {
+func testMultiHopReceiverPreimageClaimSimpleTaprootFinal(ht *lntest.HarnessTest) { //nolint:ll
c := lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
// Create a three hop network: Alice -> Bob -> Carol, using production
@@ -850,8 +854,12 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -1134,7 +1142,7 @@ func testLocalForceCloseBeforeTimeoutSimpleTaprootZeroConf(
// testLocalForceCloseBeforeTimeoutSimpleTaprootFinal tests
// `runLocalForceCloseBeforeHtlcTimeout` with production simple taproot channel.
-func testLocalForceCloseBeforeTimeoutSimpleTaprootFinal(ht *lntest.HarnessTest) {
+func testLocalForceCloseBeforeTimeoutSimpleTaprootFinal(ht *lntest.HarnessTest) { //nolint:ll
c := lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
// Create a three hop network: Alice -> Bob -> Carol, using production
@@ -1251,8 +1259,12 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -1523,8 +1535,9 @@ func testRemoteForceCloseBeforeTimeoutSimpleTaproot(ht *lntest.HarnessTest) {
}
// testRemoteForceCloseBeforeTimeoutSimpleTaprootFinal tests
-// `runRemoteForceCloseBeforeHtlcTimeout` with production simple taproot channel.
-func testRemoteForceCloseBeforeTimeoutSimpleTaprootFinal(ht *lntest.HarnessTest) {
+// `runRemoteForceCloseBeforeHtlcTimeout` with production simple taproot
+// channel.
+func testRemoteForceCloseBeforeTimeoutSimpleTaprootFinal(ht *lntest.HarnessTest) { //nolint:ll
c := lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
// Create a three hop network: Alice -> Bob -> Carol, using production
@@ -1638,8 +1651,12 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -1893,7 +1910,7 @@ func testLocalClaimIncomingHTLCSimpleTaprootFinal(ht *lntest.HarnessTest) {
// testLocalClaimIncomingHTLCSimpleTaprootFinalZeroConf tests
// `runLocalClaimIncomingHTLC` with zero-conf production simple taproot channel.
-func testLocalClaimIncomingHTLCSimpleTaprootFinalZeroConf(ht *lntest.HarnessTest) {
+func testLocalClaimIncomingHTLCSimpleTaprootFinalZeroConf(ht *lntest.HarnessTest) { //nolint:ll
c := lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
// Create a three hop network: Alice -> Bob -> Carol, using zero-conf
@@ -1941,8 +1958,12 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -2616,8 +2637,12 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}
@@ -3278,8 +3303,12 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
aliceRouteHints []*lnrpc.RouteHint
)
- if params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- params.CommitmentType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ isTaproot := params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT ||
+ params.CommitmentType ==
+ lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
+
+ if isTaproot {
carolRouteHints = makeRouteHints(bob, carol, params.ZeroConf)
aliceRouteHints = makeRouteHints(bob, alice, params.ZeroConf)
}
diff --git a/itest/lnd_payment_test.go b/itest/lnd_payment_test.go
index 06c6745..5b69371 100644
--- a/itest/lnd_payment_test.go
+++ b/itest/lnd_payment_test.go
@@ -710,7 +710,8 @@ func runAsyncPayments(ht *lntest.HarnessTest, alice, bob *node.HarnessNode,
chanArgs.CommitmentType = *commitType
if *commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
- *commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+ *commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL { //nolint:ll
+
chanArgs.Private = true
}
}
diff --git a/itest/lnd_psbt_test.go b/itest/lnd_psbt_test.go
index 1dd9dea..e0c0740 100644
--- a/itest/lnd_psbt_test.go
+++ b/itest/lnd_psbt_test.go
@@ -147,6 +147,7 @@ func runPsbtChanFundingWithNodes(ht *lntest.HarnessTest, carol,
// that an internal key is included.
if commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+
decodedPSBT, err := psbt.NewFromRawBytes(
bytes.NewReader(tempPsbt), false,
)
diff --git a/itest/lnd_remote_signer_test.go b/itest/lnd_remote_signer_test.go
index 5d45455..db1e283 100644
--- a/itest/lnd_remote_signer_test.go
+++ b/itest/lnd_remote_signer_test.go
@@ -160,6 +160,7 @@ func prepareRemoteSignerTest(ht *lntest.HarnessTest, tc remoteSignerTestCase) (
var commitArgs []string
if tc.commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT ||
tc.commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL {
+
commitArgs = lntest.NodeArgsForCommitType(
tc.commitType,
)
diff --git a/lnwallet/channel_revoke_nonces_test.go b/lnwallet/channel_revoke_nonces_test.go
index 81848d4..53d614a 100644
--- a/lnwallet/channel_revoke_nonces_test.go
+++ b/lnwallet/channel_revoke_nonces_test.go
@@ -76,26 +76,30 @@ func TestRevokeAndAckTaprootLocalNonces(t *testing.T) {
chanType := channeldb.SimpleTaprootFeatureBit
- t.Run("legacy nonce type only populates LocalNonce", func(t *testing.T) {
- t.Parallel()
-
- // Staging taproot channels populate only the
- // LocalNonce field (legacy behavior).
- revMsg, _, _, err := generateAndProcessRevocation(
- t, chanType, nil,
- )
- require.NoError(t, err)
-
- // Verify only LocalNonce is populated (legacy behavior).
- require.True(
- t, revMsg.LocalNonce.IsSome(),
- "LocalNonce should be populated for legacy nonce type",
- )
- require.True(
- t, revMsg.LocalNonces.IsNone(),
- "LocalNonces should NOT be populated for legacy nonce type",
- )
- })
+ t.Run("legacy nonce type only populates LocalNonce",
+ func(t *testing.T) {
+ t.Parallel()
+
+ // Staging taproot channels populate only the
+ // LocalNonce field (legacy behavior).
+ revMsg, _, _, err := generateAndProcessRevocation(
+ t, chanType, nil,
+ )
+ require.NoError(t, err)
+
+ // Verify only LocalNonce is populated (legacy
+ // behavior).
+ require.True(
+ t, revMsg.LocalNonce.IsSome(),
+ "LocalNonce should be populated for legacy "+
+ "nonce type",
+ )
+ require.True(
+ t, revMsg.LocalNonces.IsNone(),
+ "LocalNonces should NOT be populated for "+
+ "legacy nonce type",
+ )
+ })
t.Run("extracted nonce from legacy field", func(t *testing.T) {
t.Parallel()
@@ -158,27 +162,27 @@ func TestRevokeAndAckTaprootLocalNonces(t *testing.T) {
)
})
- t.Run("receive with only LocalNonce field (legacy peer)", func(t *testing.T) {
- t.Parallel()
+ t.Run("receive with only LocalNonce field (legacy peer)",
+ func(t *testing.T) {
+ t.Parallel()
- // Modify the message to clear the LocalNonces field.
- clearLocalNonces := func(rev *lnwire.RevokeAndAck) {
- rev.LocalNonces = lnwire.OptLocalNonces{}
- }
+ // Modify the message to clear the LocalNonces field.
+ clearLocalNonces := func(rev *lnwire.RevokeAndAck) {
+ rev.LocalNonces = lnwire.OptLocalNonces{}
+ }
- // This should should successfully process with only LocalNonce
- // (backwards compat).
- _, _, _, err := generateAndProcessRevocation(
- t, chanType, clearLocalNonces,
- )
- require.NoError(
- t, err,
- "should successfully process "+
- "revocation with only LocalNonce for "+
- "backwards compatibility",
- )
-
- })
+ // Processing should still succeed with only LocalNonce
+ // (backwards compat).
+ _, _, _, err := generateAndProcessRevocation(
+ t, chanType, clearLocalNonces,
+ )
+ require.NoError(
+ t, err,
+ "successfully process "+
+ "revocation with only LocalNonce for "+
+ "backwards compatibility",
+ )
+ })
t.Run("error when LocalNonces map is empty", func(t *testing.T) {
t.Parallel()
@@ -187,11 +191,13 @@ func TestRevokeAndAckTaprootLocalNonces(t *testing.T) {
// LocalNonce.
emptyMap := func(rev *lnwire.RevokeAndAck) {
rev.LocalNonce = lnwire.OptMusig2NonceTLV{}
+
+ emptyNonces := make(
+ map[chainhash.Hash]lnwire.Musig2Nonce,
+ )
rev.LocalNonces = lnwire.SomeLocalNonces(
lnwire.LocalNoncesData{
- NoncesMap: make(
- map[chainhash.Hash]lnwire.Musig2Nonce,
- ),
+ NoncesMap: emptyNonces,
},
)
}
diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go
index 3c94c3c..7afe2af 100644
--- a/lnwallet/channel_test.go
+++ b/lnwallet/channel_test.go
@@ -3630,7 +3630,8 @@ func TestChanSyncTaprootLocalNonces(t *testing.T) {
t.Run("final taproot only populates LocalNonces", func(t *testing.T) {
// Final taproot channels populate only the map-based
// LocalNonces field.
- aliceChanSyncMsg, err := aliceFinalChan.channelState.ChanSyncMsg()
+ aliceFinalState := aliceFinalChan.channelState
+ aliceChanSyncMsg, err := aliceFinalState.ChanSyncMsg()
require.NoError(t, err)
// Only LocalNonces should be populated.
@@ -3645,7 +3646,8 @@ func TestChanSyncTaprootLocalNonces(t *testing.T) {
// Final taproot channels send messages with only the
// LocalNonces field populated. Verify that the receiving side
// can process such a message.
- aliceChanSyncMsg, err := aliceFinalChan.channelState.ChanSyncMsg()
+ aliceFinalState := aliceFinalChan.channelState
+ aliceChanSyncMsg, err := aliceFinalState.ChanSyncMsg()
require.NoError(t, err)
bobChanSyncMsg, err := bobFinalChan.channelState.ChanSyncMsg()
require.NoError(t, err)
diff --git a/lnwallet/commitment.go b/lnwallet/commitment.go
index 74348ee..f715b93 100644
--- a/lnwallet/commitment.go
+++ b/lnwallet/commitment.go
@@ -445,7 +445,8 @@ func SecondLevelHtlcScript(chanType channeldb.ChannelType, initiator bool,
}
return input.TaprootSecondLevelScriptTree(
- revocationKey, delayKey, csvDelay, auxLeaf, scriptOpts...,
+ revocationKey, delayKey, csvDelay, auxLeaf,
+ scriptOpts...,
)
// If we are the initiator of a leased channel, then we have an
@@ -1183,7 +1184,8 @@ func genSegwitV0HtlcScript(chanType channeldb.ChannelType,
// channel.
func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
timeout uint32, rHash [32]byte, keyRing *CommitmentKeyRing,
- auxLeaf input.AuxTapLeaf, opts ...input.TaprootScriptOpt) (*input.HtlcScriptTree, error) {
+ auxLeaf input.AuxTapLeaf,
+ opts ...input.TaprootScriptOpt) (*input.HtlcScriptTree, error) {
var (
htlcScriptTree *input.HtlcScriptTree
@@ -1200,7 +1202,8 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
case isIncoming && whoseCommit.IsLocal():
htlcScriptTree, err = input.ReceiverHTLCScriptTaproot(
timeout, keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
- keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf, opts...,
+ keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf,
+ opts...,
)
// We're being paid via an HTLC by the remote party, and the HTLC is
@@ -1209,7 +1212,8 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
case isIncoming && whoseCommit.IsRemote():
htlcScriptTree, err = input.SenderHTLCScriptTaproot(
keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
- keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf, opts...,
+ keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf,
+ opts...,
)
// We're sending an HTLC which is being added to our commitment
@@ -1218,7 +1222,8 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
case !isIncoming && whoseCommit.IsLocal():
htlcScriptTree, err = input.SenderHTLCScriptTaproot(
keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
- keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf, opts...,
+ keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf,
+ opts...,
)
// Finally, we're paying the remote party via an HTLC, which is being
@@ -1227,7 +1232,8 @@ func GenTaprootHtlcScript(isIncoming bool, whoseCommit lntypes.ChannelParty,
case !isIncoming && whoseCommit.IsRemote():
htlcScriptTree, err = input.ReceiverHTLCScriptTaproot(
timeout, keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
- keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf, opts...,
+ keyRing.RevocationKey, rHash[:], whoseCommit, auxLeaf,
+ opts...,
)
}
@@ -1259,7 +1265,8 @@ func genHtlcScript(chanType channeldb.ChannelType, isIncoming bool,
}
return GenTaprootHtlcScript(
- isIncoming, whoseCommit, timeout, rHash, keyRing, auxLeaf, scriptOpts...,
+ isIncoming, whoseCommit, timeout, rHash, keyRing, auxLeaf,
+ scriptOpts...,
)
}
diff --git a/lnwallet/musig_session.go b/lnwallet/musig_session.go
index 8da961f..01f68b7 100644
--- a/lnwallet/musig_session.go
+++ b/lnwallet/musig_session.go
@@ -450,7 +450,7 @@ func (m *MusigSession) VerificationNonce() *musig2.Nonces {
// generation, if available. This is only populated when customNonceRand is set
// (test vector generation mode). The value is cleared after being read to
// prevent accidental nonce reuse.
-func (m *MusigSession) lastSigningSecNonce() fn.Option[[musig2.SecNonceSize]byte] {
+func (m *MusigSession) lastSigningSecNonce() fn.Option[[musig2.SecNonceSize]byte] { //nolint:ll
nonce := m.lastSecNonce
m.lastSecNonce = fn.None[[musig2.SecNonceSize]byte]()
return nonce
diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go
index 908759b..83a0829 100644
--- a/lnwallet/reservation.go
+++ b/lnwallet/reservation.go
@@ -53,10 +53,11 @@ const (
// the staging version using feature bits 180/181.
CommitmentTypeSimpleTaproot
- // CommitmentTypeSimpleTaprootFinal is the production commitment type for
- // taproot channels that use a musig2 funding output and the tapscript tree
- // where relevant for the commitment transaction pk scripts. This uses the
- // final feature bits 80/81 and production scripts.
+ // CommitmentTypeSimpleTaprootFinal is the production commitment type
+ // for taproot channels that use a musig2 funding output and the
+ // tapscript tree where relevant for the commitment transaction pk
+ // scripts. This uses the final feature bits 80/81 and production
+ // scripts.
CommitmentTypeSimpleTaprootFinal
// CommitmentTypeSimpleTaprootOverlay builds on the existing
diff --git a/lnwallet/taproot_test_vectors_test.go b/lnwallet/taproot_test_vectors_test.go
index baf3a1c..7e3dcf8 100644
--- a/lnwallet/taproot_test_vectors_test.go
+++ b/lnwallet/taproot_test_vectors_test.go
@@ -150,6 +150,7 @@ func deriveKeyFromSeed(seed []byte, label string) *btcec.PrivateKey {
keyBytes := h.Sum(nil)
privKey, _ := btcec.PrivKeyFromBytes(keyBytes)
+
return privKey
}
@@ -249,15 +250,11 @@ func (tc *taprootTestContext) commitPoint() *btcec.PublicKey {
return input.ComputeCommitmentPoint(tc.localPerCommitSecret[:])
}
-// ---------------------------------------------------------------------------
-// JSON output types
-// ---------------------------------------------------------------------------
-
// TaprootTestVectors is the top-level JSON structure for taproot test vectors.
type TaprootTestVectors struct {
- Params TestVectorParams `json:"params"`
- Scripts ScriptVectors `json:"scripts"`
- Transactions []TransactionTestCase `json:"transactions"`
+ Params TestVectorParams `json:"params"`
+ Scripts ScriptVectors `json:"scripts"`
+ Transactions []TransactionTestCase `json:"transactions"`
}
// TestVectorParams holds the seed, channel parameters, and all keys.
@@ -278,18 +275,18 @@ type KeySet struct {
RemoteFundingPrivkey string `json:"remote_funding_privkey"`
RemoteFundingPubkey string `json:"remote_funding_pubkey"`
- LocalPaymentBasepointSecret string `json:"local_payment_basepoint_secret"`
- LocalPaymentBasepoint string `json:"local_payment_basepoint"`
- RemotePaymentBasepointSecret string `json:"remote_payment_basepoint_secret"`
+ LocalPaymentBasepointSecret string `json:"local_payment_basepoint_secret"` //nolint:ll
+ LocalPaymentBasepoint string `json:"local_payment_basepoint"`
+ RemotePaymentBasepointSecret string `json:"remote_payment_basepoint_secret"` //nolint:ll
RemotePaymentBasepoint string `json:"remote_payment_basepoint"`
- LocalDelayedPaymentBasepointSecret string `json:"local_delayed_payment_basepoint_secret"`
- LocalDelayedPaymentBasepoint string `json:"local_delayed_payment_basepoint"`
- RemoteRevocationBasepointSecret string `json:"remote_revocation_basepoint_secret"`
- RemoteRevocationBasepoint string `json:"remote_revocation_basepoint"`
+ LocalDelayedPaymentBasepointSecret string `json:"local_delayed_payment_basepoint_secret"` //nolint:ll
+ LocalDelayedPaymentBasepoint string `json:"local_delayed_payment_basepoint"` //nolint:ll
+ RemoteRevocationBasepointSecret string `json:"remote_revocation_basepoint_secret"` //nolint:ll
+ RemoteRevocationBasepoint string `json:"remote_revocation_basepoint"` //nolint:ll
- LocalHtlcBasepointSecret string `json:"local_htlc_basepoint_secret"`
- LocalHtlcBasepoint string `json:"local_htlc_basepoint"`
+ LocalHtlcBasepointSecret string `json:"local_htlc_basepoint_secret"`
+ LocalHtlcBasepoint string `json:"local_htlc_basepoint"`
RemoteHtlcBasepointSecret string `json:"remote_htlc_basepoint_secret"`
RemoteHtlcBasepoint string `json:"remote_htlc_basepoint"`
@@ -297,17 +294,17 @@ type KeySet struct {
LocalPerCommitPoint string `json:"local_per_commit_point"`
// Derived per-commitment keys.
- DerivedLocalDelayedPubkey string `json:"derived_local_delayed_pubkey"`
- DerivedRevocationPubkey string `json:"derived_revocation_pubkey"`
- DerivedLocalHtlcPubkey string `json:"derived_local_htlc_pubkey"`
- DerivedRemoteHtlcPubkey string `json:"derived_remote_htlc_pubkey"`
+ DerivedLocalDelayedPubkey string `json:"derived_local_delayed_pubkey"`
+ DerivedRevocationPubkey string `json:"derived_revocation_pubkey"`
+ DerivedLocalHtlcPubkey string `json:"derived_local_htlc_pubkey"`
+ DerivedRemoteHtlcPubkey string `json:"derived_remote_htlc_pubkey"`
DerivedRemotePaymentPubkey string `json:"derived_remote_payment_pubkey"`
}
// ScriptVectorEntry represents a single tapscript tree decomposition.
type ScriptVectorEntry struct {
// For scripts with named leaves.
- Scripts map[string]string `json:"scripts,omitempty"`
+ Scripts map[string]string `json:"scripts,omitempty"`
LeafHashes map[string]string `json:"leaf_hashes,omitempty"`
TapscriptRoot string `json:"tapscript_root"`
@@ -330,12 +327,12 @@ type ScriptVectors struct {
ToRemote ScriptVectorEntry `json:"to_remote"`
LocalAnchor ScriptVectorEntry `json:"local_anchor"`
RemoteAnchor ScriptVectorEntry `json:"remote_anchor"`
- OfferedHtlcLocalCommit ScriptVectorEntry `json:"offered_htlc_local_commit"`
- OfferedHtlcRemoteCommit ScriptVectorEntry `json:"offered_htlc_remote_commit"`
- AcceptedHtlcLocalCommit ScriptVectorEntry `json:"accepted_htlc_local_commit"`
- AcceptedHtlcRemoteCommit ScriptVectorEntry `json:"accepted_htlc_remote_commit"`
- SecondLevelHtlcSuccess ScriptVectorEntry `json:"second_level_htlc_success"`
- SecondLevelHtlcTimeout ScriptVectorEntry `json:"second_level_htlc_timeout"`
+ OfferedHtlcLocalCommit ScriptVectorEntry `json:"offered_htlc_local_commit"` //nolint:ll
+ OfferedHtlcRemoteCommit ScriptVectorEntry `json:"offered_htlc_remote_commit"` //nolint:ll
+ AcceptedHtlcLocalCommit ScriptVectorEntry `json:"accepted_htlc_local_commit"` //nolint:ll
+ AcceptedHtlcRemoteCommit ScriptVectorEntry `json:"accepted_htlc_remote_commit"` //nolint:ll
+ SecondLevelHtlcSuccess ScriptVectorEntry `json:"second_level_htlc_success"` //nolint:ll
+ SecondLevelHtlcTimeout ScriptVectorEntry `json:"second_level_htlc_timeout"` //nolint:ll
}
// HtlcDesc describes an HTLC resolution in the transaction vectors.
@@ -346,33 +343,29 @@ type HtlcDesc struct {
// HtlcInput describes an HTLC added to the channel for a test case.
type HtlcInput struct {
- Incoming bool `json:"incoming"`
+ Incoming bool `json:"incoming"`
AmountMsat uint64 `json:"amount_msat"`
- Expiry uint32 `json:"expiry"`
- Preimage string `json:"preimage"`
+ Expiry uint32 `json:"expiry"`
+ Preimage string `json:"preimage"`
}
// TransactionTestCase is one transaction test vector.
type TransactionTestCase struct {
- Name string `json:"name"`
- LocalBalanceMsat uint64 `json:"local_balance_msat"`
- RemoteBalanceMsat uint64 `json:"remote_balance_msat"`
- FeePerKw int64 `json:"fee_per_kw"`
- DustLimitSatoshis int64 `json:"dust_limit_satoshis,omitempty"`
+ Name string `json:"name"`
+ LocalBalanceMsat uint64 `json:"local_balance_msat"`
+ RemoteBalanceMsat uint64 `json:"remote_balance_msat"`
+ FeePerKw int64 `json:"fee_per_kw"`
+ DustLimitSatoshis int64 `json:"dust_limit_satoshis,omitempty"` //nolint:ll
Htlcs []HtlcInput `json:"htlcs"`
- LocalSecNonce string `json:"local_sec_nonce"`
- RemoteSecNonce string `json:"remote_sec_nonce"`
- LocalNonce string `json:"local_nonce"`
- RemoteNonce string `json:"remote_nonce"`
- RemotePartialSig string `json:"remote_partial_sig"`
- ExpectedCommitmentTxHex string `json:"expected_commitment_tx_hex"`
- HtlcDescs []HtlcDesc `json:"htlc_descs"`
+ LocalSecNonce string `json:"local_sec_nonce"`
+ RemoteSecNonce string `json:"remote_sec_nonce"`
+ LocalNonce string `json:"local_nonce"`
+ RemoteNonce string `json:"remote_nonce"`
+ RemotePartialSig string `json:"remote_partial_sig"`
+ ExpectedCommitmentTxHex string `json:"expected_commitment_tx_hex"`
+ HtlcDescs []HtlcDesc `json:"htlc_descs"`
}
-// ---------------------------------------------------------------------------
-// Script vector generation (Section A)
-// ---------------------------------------------------------------------------
-
// generateParams populates the params section of the test vectors.
func (tc *taprootTestContext) generateParams() TestVectorParams {
commitPt := tc.commitPoint()
@@ -390,6 +383,7 @@ func (tc *taprootTestContext) generateParams() TestVectorParams {
remoteHtlcPubkey := input.TweakPubKey(
tc.remoteHtlcBasepointSecret.PubKey(), commitPt,
)
+
// For tweakless channels, the remote payment key is untweaked.
remotePaymentPubkey := tc.remotePaymentBasepointSecret.PubKey()
@@ -401,28 +395,58 @@ func (tc *taprootTestContext) generateParams() TestVectorParams {
CommitHeight: tc.commitHeight,
NumsPoint: input.TaprootNUMSHex,
Keys: KeySet{
- LocalFundingPrivkey: privHex(tc.localFundingPrivkey),
- LocalFundingPubkey: pubHex(tc.localFundingPrivkey.PubKey()),
+ LocalFundingPrivkey: privHex(tc.localFundingPrivkey),
+ LocalFundingPubkey: pubHex(
+ tc.localFundingPrivkey.PubKey(),
+ ),
RemoteFundingPrivkey: privHex(tc.remoteFundingPrivkey),
- RemoteFundingPubkey: pubHex(tc.remoteFundingPrivkey.PubKey()),
+ RemoteFundingPubkey: pubHex(
+ tc.remoteFundingPrivkey.PubKey(),
+ ),
- LocalPaymentBasepointSecret: privHex(tc.localPaymentBasepointSecret),
- LocalPaymentBasepoint: pubHex(tc.localPaymentBasepointSecret.PubKey()),
- RemotePaymentBasepointSecret: privHex(tc.remotePaymentBasepointSecret),
- RemotePaymentBasepoint: pubHex(tc.remotePaymentBasepointSecret.PubKey()),
+ LocalPaymentBasepointSecret: privHex(
+ tc.localPaymentBasepointSecret,
+ ),
+ LocalPaymentBasepoint: pubHex(
+ tc.localPaymentBasepointSecret.PubKey(),
+ ),
+ RemotePaymentBasepointSecret: privHex(
+ tc.remotePaymentBasepointSecret,
+ ),
+ RemotePaymentBasepoint: pubHex(
+ tc.remotePaymentBasepointSecret.PubKey(),
+ ),
- LocalDelayedPaymentBasepointSecret: privHex(tc.localDelayedPaymentBasepointSecret),
- LocalDelayedPaymentBasepoint: pubHex(tc.localDelayedPaymentBasepointSecret.PubKey()),
- RemoteRevocationBasepointSecret: privHex(tc.remoteRevocationBasepointSecret),
- RemoteRevocationBasepoint: pubHex(tc.remoteRevocationBasepointSecret.PubKey()),
+ LocalDelayedPaymentBasepointSecret: privHex(
+ tc.localDelayedPaymentBasepointSecret,
+ ),
+ LocalDelayedPaymentBasepoint: pubHex(
+ tc.localDelayedPaymentBasepointSecret.PubKey(),
+ ),
+ RemoteRevocationBasepointSecret: privHex(
+ tc.remoteRevocationBasepointSecret,
+ ),
+ RemoteRevocationBasepoint: pubHex(
+ tc.remoteRevocationBasepointSecret.PubKey(),
+ ),
- LocalHtlcBasepointSecret: privHex(tc.localHtlcBasepointSecret),
- LocalHtlcBasepoint: pubHex(tc.localHtlcBasepointSecret.PubKey()),
- RemoteHtlcBasepointSecret: privHex(tc.remoteHtlcBasepointSecret),
- RemoteHtlcBasepoint: pubHex(tc.remoteHtlcBasepointSecret.PubKey()),
+ LocalHtlcBasepointSecret: privHex(
+ tc.localHtlcBasepointSecret,
+ ),
+ LocalHtlcBasepoint: pubHex(
+ tc.localHtlcBasepointSecret.PubKey(),
+ ),
+ RemoteHtlcBasepointSecret: privHex(
+ tc.remoteHtlcBasepointSecret,
+ ),
+ RemoteHtlcBasepoint: pubHex(
+ tc.remoteHtlcBasepointSecret.PubKey(),
+ ),
- LocalPerCommitSecret: hex.EncodeToString(tc.localPerCommitSecret[:]),
- LocalPerCommitPoint: pubHex(commitPt),
+ LocalPerCommitSecret: hex.EncodeToString(
+ tc.localPerCommitSecret[:],
+ ),
+ LocalPerCommitPoint: pubHex(commitPt),
DerivedLocalDelayedPubkey: pubHex(localDelayedPubkey),
DerivedRevocationPubkey: pubHex(revocationPubkey),
@@ -614,7 +638,8 @@ func (tc *taprootTestContext) generateScriptVectors() ScriptVectors {
// Use HTLC 0 for offered/accepted HTLC vectors.
preimage0, err := lntypes.MakePreimageFromStr(
- "0000000000000000000000000000000000000000000000000000000000000000",
+ "00000000000000000000000000000000000000000000" +
+ "00000000000000000000",
)
require.NoError(t, err)
payHash0 := preimage0.Hash()
@@ -659,10 +684,10 @@ func (tc *taprootTestContext) generateScriptVectors() ScriptVectors {
)
require.NoError(t, err)
- // 9. Second-level HTLC timeout (same function, different keys in a
- // real scenario, but for vectors we show the construction with the
- // same delay key since second-level success and timeout share the
- // same script tree structure).
+ // 9. Second-level HTLC timeout (same function, different keys in a real
+ // scenario, but for vectors we show the construction with the same
+ // delay key since second-level success and timeout share the same
+ // script tree structure).
secondLevelTimeout, err := input.TaprootSecondLevelScriptTree(
revocationPubkey, localDelayedPubkey,
uint32(tc.localCsvDelay), noAux,
@@ -671,17 +696,29 @@ func (tc *taprootTestContext) generateScriptVectors() ScriptVectors {
require.NoError(t, err)
return ScriptVectors{
- Funding: tc.generateFundingVector(),
- ToLocal: commitScriptTreeToEntry(toLocalTree),
- ToRemote: commitScriptTreeToEntry(toRemoteTree),
- LocalAnchor: anchorScriptTreeToEntry(localAnchorTree),
- RemoteAnchor: anchorScriptTreeToEntry(remoteAnchorTree),
- OfferedHtlcLocalCommit: htlcScriptTreeToEntry(offeredLocalTree),
- OfferedHtlcRemoteCommit: htlcScriptTreeToEntry(offeredRemoteTree),
- AcceptedHtlcLocalCommit: htlcScriptTreeToEntry(acceptedLocalTree),
- AcceptedHtlcRemoteCommit: htlcScriptTreeToEntry(acceptedRemoteTree),
- SecondLevelHtlcSuccess: secondLevelScriptTreeToEntry(secondLevelSuccess),
- SecondLevelHtlcTimeout: secondLevelScriptTreeToEntry(secondLevelTimeout),
+ Funding: tc.generateFundingVector(),
+ ToLocal: commitScriptTreeToEntry(toLocalTree),
+ ToRemote: commitScriptTreeToEntry(toRemoteTree),
+ LocalAnchor: anchorScriptTreeToEntry(localAnchorTree),
+ RemoteAnchor: anchorScriptTreeToEntry(
+ remoteAnchorTree,
+ ),
+ OfferedHtlcLocalCommit: htlcScriptTreeToEntry(offeredLocalTree),
+ OfferedHtlcRemoteCommit: htlcScriptTreeToEntry(
+ offeredRemoteTree,
+ ),
+ AcceptedHtlcLocalCommit: htlcScriptTreeToEntry(
+ acceptedLocalTree,
+ ),
+ AcceptedHtlcRemoteCommit: htlcScriptTreeToEntry(
+ acceptedRemoteTree,
+ ),
+ SecondLevelHtlcSuccess: secondLevelScriptTreeToEntry(
+ secondLevelSuccess,
+ ),
+ SecondLevelHtlcTimeout: secondLevelScriptTreeToEntry(
+ secondLevelTimeout,
+ ),
}
}
@@ -818,7 +855,7 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
feePerKw := chainfee.SatPerKWeight(feeRate)
commitWeight := lntypes.WeightUnit(input.AnchorCommitWeight)
commitFee := feePerKw.FeeForWeight(commitWeight)
- anchorAmt := btcutil.Amount(2 * AnchorSize)
+ anchorAmt := btcutil.Amount(2 * AnchorSize) //nolint:unconvert
remoteCommitTx, localCommitTx, err := CreateCommitmentTxns(
remoteBalance, localBalance-commitFee,
@@ -830,17 +867,21 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
var commitHeight = tc.commitHeight - 1
remoteCommit := channeldb.ChannelCommitment{
- CommitHeight: commitHeight,
- LocalBalance: lnwire.NewMSatFromSatoshis(remoteBalance),
- RemoteBalance: lnwire.NewMSatFromSatoshis(localBalance - commitFee - anchorAmt),
- CommitFee: commitFee,
- FeePerKw: btcutil.Amount(feePerKw),
- CommitTx: remoteCommitTx,
- CommitSig: testSigBytes,
+ CommitHeight: commitHeight,
+ LocalBalance: lnwire.NewMSatFromSatoshis(remoteBalance),
+ RemoteBalance: lnwire.NewMSatFromSatoshis(
+ localBalance - commitFee - anchorAmt,
+ ),
+ CommitFee: commitFee,
+ FeePerKw: btcutil.Amount(feePerKw),
+ CommitTx: remoteCommitTx,
+ CommitSig: testSigBytes,
}
localCommit := channeldb.ChannelCommitment{
- CommitHeight: commitHeight,
- LocalBalance: lnwire.NewMSatFromSatoshis(localBalance - commitFee - anchorAmt),
+ CommitHeight: commitHeight,
+ LocalBalance: lnwire.NewMSatFromSatoshis(
+ localBalance - commitFee - anchorAmt,
+ ),
RemoteBalance: lnwire.NewMSatFromSatoshis(remoteBalance),
CommitFee: commitFee,
FeePerKw: btcutil.Amount(feePerKw),
@@ -865,8 +906,10 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
LocalCommitment: remoteCommit,
RemoteCommitment: remoteCommit,
Db: dbRemote.ChannelStateDB(),
- Packager: channeldb.NewChannelPackager(shortChanID),
- FundingTxn: fundingTx,
+ Packager: channeldb.NewChannelPackager(
+ shortChanID,
+ ),
+ FundingTxn: fundingTx,
}
localChannelState := &channeldb.OpenChannel{
LocalChanCfg: localCfg,
@@ -883,8 +926,10 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
LocalCommitment: localCommit,
RemoteCommitment: localCommit,
Db: dbLocal.ChannelStateDB(),
- Packager: channeldb.NewChannelPackager(shortChanID),
- FundingTxn: fundingTx,
+ Packager: channeldb.NewChannelPackager(
+ shortChanID,
+ ),
+ FundingTxn: fundingTx,
}
// Create mock signers with all deterministic keys. The funding key must
@@ -917,8 +962,12 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
// Derive deterministic signing rand for JIT nonces so MuSig2
// signatures are reproducible across runs.
- localRandHash := sha256.Sum256(append(tc.seed, []byte("local-signing-rand")...))
- remoteRandHash := sha256.Sum256(append(tc.seed, []byte("remote-signing-rand")...))
+ localRandHash := sha256.Sum256(
+ append(tc.seed, []byte("local-signing-rand")...),
+ )
+ remoteRandHash := sha256.Sum256(
+ append(tc.seed, []byte("remote-signing-rand")...),
+ )
auxSigner := NewDefaultAuxSignerMock(t)
remotePool := NewSigPool(1, remoteSigner)
@@ -978,26 +1027,26 @@ func createTaprootTestChannelsForVectors(tc *taprootTestContext,
// taprootTransactionTestCases defines the set of transaction test cases.
var taprootTransactionTestCases = []struct {
- name string
- localBalance lnwire.MilliSatoshi
+ name string
+ localBalance lnwire.MilliSatoshi
remoteBalance lnwire.MilliSatoshi
- feePerKw btcutil.Amount
- dustLimit btcutil.Amount
- useTestHtlcs bool
+ feePerKw btcutil.Amount
+ dustLimit btcutil.Amount
+ useTestHtlcs bool
}{
{
- name: "simple commitment tx with no HTLCs",
- localBalance: 7_000_000_000,
+ name: "simple commitment tx with no HTLCs",
+ localBalance: 7_000_000_000,
remoteBalance: 3_000_000_000,
- feePerKw: 15_000,
- useTestHtlcs: false,
+ feePerKw: 15_000,
+ useTestHtlcs: false,
},
{
- name: "commitment tx with five HTLCs untrimmed",
- localBalance: 6_988_000_000,
+ name: "commitment tx with five HTLCs untrimmed",
+ localBalance: 6_988_000_000,
remoteBalance: 3_000_000_000,
- feePerKw: 644,
- useTestHtlcs: true,
+ feePerKw: 644,
+ useTestHtlcs: true,
},
{
name: "commitment tx with some HTLCs trimmed",
@@ -1010,7 +1059,7 @@ var taprootTransactionTestCases = []struct {
}
// generateTransactionVectors generates all transaction test vectors.
-func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase {
+func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase { //nolint:ll
t := tc.t
var results []TransactionTestCase
@@ -1040,7 +1089,7 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
remoteBalance+localBalance,
)
- remoteChannel, localChannel := createTaprootTestChannelsForVectors(
+ remoteChannel, localChannel := createTaprootTestChannelsForVectors( //nolint:ll
tc, testCase.feePerKw,
remoteBalance.ToSatoshis(),
localBalance.ToSatoshis(),
@@ -1064,12 +1113,12 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
localChannel.musigSessions.RemoteSession.lastSigningSecNonce()
// Capture local's verification nonce for local's own
- // commitment. This is the nonce local contributes to the
- // MuSig2 session for the commitment tx stored in the test
- // vector (which is local's commitment, obtained via
- // ForceClose). We must capture it BEFORE
- // ReceiveNewCommitment finalizes the local session.
- localVerifNonce := localChannel.musigSessions.LocalSession.VerificationNonce()
+ // commitment. This is the nonce local contributes to the MuSig2
+ // session for the commitment tx stored in the test vector
+ // (which is local's commitment, obtained via ForceClose). We
+ // must capture it BEFORE ReceiveNewCommitment finalizes the
+ // local session.
+ localVerifNonce := localChannel.musigSessions.LocalSession.VerificationNonce() //nolint:ll
localNonceHex := hex.EncodeToString(
localVerifNonce.PubNonce[:],
)
@@ -1092,7 +1141,7 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
require.NoError(t, err)
// Capture the remote secret nonce from the musig session.
- remoteSecNonceBytes := remoteChannel.musigSessions.RemoteSession.lastSigningSecNonce().UnwrapOrFail(t)
+ remoteSecNonceBytes := remoteChannel.musigSessions.RemoteSession.lastSigningSecNonce().UnwrapOrFail(t) //nolint:ll
remoteSecNonceHex := hex.EncodeToString(
remoteSecNonceBytes[:],
)
@@ -1125,7 +1174,7 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
// Collect HTLC resolution transactions.
var htlcDescs []HtlcDesc
if testCase.useTestHtlcs {
- resolutions := forceCloseSum.ContractResolutions.UnwrapOrFail(t)
+ resolutions := forceCloseSum.ContractResolutions.UnwrapOrFail(t) //nolint:ll
htlcResolutions := resolutions.HtlcResolutions
// Build a map from commitment tx output index to
@@ -1170,7 +1219,7 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
// Sort by output index to match HtlcSigs ordering.
sort.Slice(allHtlcs, func(a, b int) bool {
- return allHtlcs[a].outputIdx < allHtlcs[b].outputIdx
+ return allHtlcs[a].outputIdx < allHtlcs[b].outputIdx //nolint:ll
})
require.Equal(t,
@@ -1181,7 +1230,7 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
for i, entry := range allHtlcs {
sigHex := hex.EncodeToString(
- remoteNewCommit.HtlcSigs[i].ToSignatureBytes(),
+ remoteNewCommit.HtlcSigs[i].ToSignatureBytes(), //nolint:ll
)
var b bytes.Buffer
@@ -1190,7 +1239,9 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
htlcDescs = append(htlcDescs, HtlcDesc{
RemotePartialSigHex: sigHex,
- ResolutionTxHex: hex.EncodeToString(b.Bytes()),
+ ResolutionTxHex: hex.EncodeToString(
+ b.Bytes(),
+ ),
})
}
}
@@ -1209,18 +1260,20 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
}
result := TransactionTestCase{
- Name: testCase.name,
- LocalBalanceMsat: uint64(testCase.localBalance),
- RemoteBalanceMsat: uint64(testCase.remoteBalance),
- FeePerKw: int64(testCase.feePerKw),
- Htlcs: htlcInputs,
- LocalSecNonce: localSecNonceHex,
- RemoteSecNonce: remoteSecNonceHex,
- LocalNonce: localNonceHex,
- RemoteNonce: remoteNonceHex,
- RemotePartialSig: remoteSigHex,
- ExpectedCommitmentTxHex: hex.EncodeToString(txBytes.Bytes()),
- HtlcDescs: htlcDescs,
+ Name: testCase.name,
+ LocalBalanceMsat: uint64(testCase.localBalance),
+ RemoteBalanceMsat: uint64(testCase.remoteBalance),
+ FeePerKw: int64(testCase.feePerKw),
+ Htlcs: htlcInputs,
+ LocalSecNonce: localSecNonceHex,
+ RemoteSecNonce: remoteSecNonceHex,
+ LocalNonce: localNonceHex,
+ RemoteNonce: remoteNonceHex,
+ RemotePartialSig: remoteSigHex,
+ ExpectedCommitmentTxHex: hex.EncodeToString(
+ txBytes.Bytes(),
+ ),
+ HtlcDescs: htlcDescs,
}
if testCase.dustLimit != 0 {
result.DustLimitSatoshis = int64(testCase.dustLimit)
@@ -1235,10 +1288,6 @@ func (tc *taprootTestContext) generateTransactionVectors() []TransactionTestCase
return results
}
-// ---------------------------------------------------------------------------
-// Main test entry point
-// ---------------------------------------------------------------------------
-
// TestTaprootVectors either generates or verifies taproot test vectors
// depending on the -generate-taproot-vectors flag.
func TestTaprootVectors(t *testing.T) {
@@ -1402,9 +1451,10 @@ func verifyTaprootVectors(t *testing.T) {
for j, storedHtlc := range storedTx.HtlcDescs {
require.Equal(t,
storedHtlc.ResolutionTxHex,
- genTx.HtlcDescs[j].ResolutionTxHex,
+ genTx.HtlcDescs[j].ResolutionTxHex, //nolint:ll
fmt.Sprintf(
- "htlc %d resolution tx mismatch", j,
+ "htlc %d resolution "+
+ "tx mismatch", j, //nolint:ll
),
)
}
@@ -1631,6 +1681,7 @@ func extractHash160FromScript(t *testing.T, script []byte) [20]byte {
var hash160 [20]byte
copy(hash160[:], data)
+
return hash160
}
}
@@ -1639,6 +1690,7 @@ func extractHash160FromScript(t *testing.T, script []byte) [20]byte {
t.Fatal("OP_HASH160 not found in script")
var zero [20]byte
+
return zero
}
diff --git a/lnwire/revoke_and_ack.go b/lnwire/revoke_and_ack.go
index 676ac01..e2a4c93 100644
--- a/lnwire/revoke_and_ack.go
+++ b/lnwire/revoke_and_ack.go
@@ -98,7 +98,7 @@ func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
if val, ok := typeMap[c.LocalNonce.TlvType()]; ok && val == nil {
c.LocalNonce = tlv.SomeRecordT(localNonce)
}
- if val, ok := typeMap[(LocalNoncesRecordTypeDef)(nil).TypeVal()]; ok && val == nil {
+ if val, ok := typeMap[(LocalNoncesRecordTypeDef)(nil).TypeVal()]; ok && val == nil { //nolint:ll
c.LocalNonces = SomeLocalNonces(localNoncesData)
}
diff --git a/lnwire/test_message.go b/lnwire/test_message.go
index 5fee057..8734440 100644
--- a/lnwire/test_message.go
+++ b/lnwire/test_message.go
@@ -1872,7 +1872,9 @@ func (c *RevokeAndAck) RandTestMessage(t *rapid.T) Message {
nonces[txid] = RandMusig2Nonce(t)
}
- msg.LocalNonces = SomeLocalNonces(LocalNoncesData{NoncesMap: nonces})
+ msg.LocalNonces = SomeLocalNonces(LocalNoncesData{
+ NoncesMap: nonces,
+ })
}
return msg
diff --git a/rpcserver.go b/rpcserver.go
index a069aa7..e62de95 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -2402,8 +2402,8 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
*channelType = lnwire.ChannelType(*fv)
case lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL:
- // If the final taproot channel type is being set, then the channel
- // MUST be private (unadvertised) for now.
+ // If the final taproot channel type is being set, then the
+ // channel MUST be private (unadvertised) for now.
if !in.Private {
return nil, fmt.Errorf("taproot channels must be " +
"private")
diff --git a/watchtower/blob/justice_kit.go b/watchtower/blob/justice_kit.go
index 61dcbe3..527cf08 100644
--- a/watchtower/blob/justice_kit.go
+++ b/watchtower/blob/justice_kit.go
@@ -320,7 +320,8 @@ func newTaprootJusticeKit(sweepScript []byte,
tree, err := input.NewLocalCommitScriptTree(
breachInfo.RemoteDelay, keyRing.ToLocalKey,
- keyRing.RevocationKey, fn.None[txscript.TapLeaf](), scriptOpts...,
+ keyRing.RevocationKey, fn.None[txscript.TapLeaf](),
+ scriptOpts...,
)
if err != nil {
return nil, err
@@ -361,7 +362,8 @@ func (t *taprootJusticeKit) ToLocalOutputSpendInfo() (*txscript.PkScript,
}
// TODO: Add channel type info to determine whether to use production
- // scripts for final taproot channels. For now, we default to staging scripts.
+ // scripts for final taproot channels. For now, we default to staging
+ // scripts.
var scriptOpts []input.TaprootScriptOpt
// if chanType.IsTaprootFinal() {
// scriptOpts = append(scriptOpts, input.WithProdScripts())
@@ -435,7 +437,8 @@ func (t *taprootJusticeKit) ToRemoteOutputSpendInfo() (*txscript.PkScript,
}
// TODO: Add channel type info to determine whether to use production
- // scripts for final taproot channels. For now, we default to staging scripts.
+ // scripts for final taproot channels. For now, we default to staging
+ // scripts.
var scriptOpts []input.TaprootScriptOpt
// if chanType.IsTaprootFinal() {
// scriptOpts = append(scriptOpts, input.WithProdScripts())
Why this scored 15/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.