Skip to content

Commit 2c9fa8d

Browse files
committed
lnwallet: export AnchorSize
1 parent e5625b8 commit 2c9fa8d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

lnwallet/channel.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8495,7 +8495,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
84958495
WitnessScript: anchorWitnessScript,
84968496
Output: &wire.TxOut{
84978497
PkScript: localAnchor.PkScript(),
8498-
Value: int64(anchorSize),
8498+
Value: int64(AnchorSize),
84998499
},
85008500
HashType: sweepSigHash(chanState.ChanType),
85018501
}
@@ -8507,7 +8507,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
85078507

85088508
//nolint:lll
85098509
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
8510-
localAnchor.PkScript(), int64(anchorSize),
8510+
localAnchor.PkScript(), int64(AnchorSize),
85118511
)
85128512

85138513
// For anchor outputs with taproot channels, the key desc is
@@ -9000,7 +9000,7 @@ func (lc *LightningChannel) LocalBalanceDust() bool {
90009000
// regain the stats allocated to the anchor outputs with the co-op
90019001
// close transaction.
90029002
if chanState.ChanType.HasAnchors() && chanState.IsInitiator {
9003-
localBalance += 2 * anchorSize
9003+
localBalance += 2 * AnchorSize
90049004
}
90059005

90069006
return localBalance <= chanState.LocalChanCfg.DustLimit
@@ -9020,7 +9020,7 @@ func (lc *LightningChannel) RemoteBalanceDust() bool {
90209020
// regain the stats allocated to the anchor outputs with the co-op
90219021
// close transaction.
90229022
if chanState.ChanType.HasAnchors() && !chanState.IsInitiator {
9023-
remoteBalance += 2 * anchorSize
9023+
remoteBalance += 2 * AnchorSize
90249024
}
90259025

90269026
return remoteBalance <= chanState.RemoteChanCfg.DustLimit

lnwallet/channel_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
712712
testCoopClose(t, &coopCloseTestCase{
713713
chanType: channeldb.SingleFunderTweaklessBit |
714714
channeldb.AnchorOutputsBit,
715-
anchorAmt: anchorSize * 2,
715+
anchorAmt: AnchorSize * 2,
716716
})
717717
})
718718
}
@@ -822,7 +822,7 @@ func TestForceClose(t *testing.T) {
822822
chanType: channeldb.SingleFunderTweaklessBit |
823823
channeldb.AnchorOutputsBit,
824824
expectedCommitWeight: input.AnchorCommitWeight,
825-
anchorAmt: anchorSize * 2,
825+
anchorAmt: AnchorSize * 2,
826826
})
827827
})
828828
t.Run("taproot", func(t *testing.T) {
@@ -831,7 +831,7 @@ func TestForceClose(t *testing.T) {
831831
channeldb.AnchorOutputsBit |
832832
channeldb.SimpleTaprootFeatureBit,
833833
expectedCommitWeight: input.TaprootCommitWeight,
834-
anchorAmt: anchorSize * 2,
834+
anchorAmt: AnchorSize * 2,
835835
})
836836
})
837837
t.Run("taproot with tapscript root", func(t *testing.T) {
@@ -841,7 +841,7 @@ func TestForceClose(t *testing.T) {
841841
channeldb.SimpleTaprootFeatureBit |
842842
channeldb.TapscriptRootBit,
843843
expectedCommitWeight: input.TaprootCommitWeight,
844-
anchorAmt: anchorSize * 2,
844+
anchorAmt: AnchorSize * 2,
845845
})
846846
})
847847
}
@@ -927,7 +927,7 @@ func testForceClose(t *testing.T, testCase *forceCloseTestCase) {
927927
t.Fatal("commit tx not referenced by anchor res")
928928
}
929929
if anchorRes.AnchorSignDescriptor.Output.Value !=
930-
int64(anchorSize) {
930+
int64(AnchorSize) {
931931

932932
t.Fatal("unexpected anchor size")
933933
}

lnwallet/commitment.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"github.com/lightningnetwork/lnd/tlv"
1919
)
2020

21-
// anchorSize is the constant anchor output size.
22-
const anchorSize = btcutil.Amount(330)
21+
// AnchorSize is the constant anchor output size.
22+
const AnchorSize = btcutil.Amount(330)
2323

2424
// DefaultAnchorsCommitMaxFeeRateSatPerVByte is the default max fee rate in
2525
// sat/vbyte the initiator will use for anchor channels. This should be enough
@@ -1155,7 +1155,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
11551155
if localOutput || numHTLCs > 0 {
11561156
commitTx.AddTxOut(&wire.TxOut{
11571157
PkScript: localAnchor.PkScript(),
1158-
Value: int64(anchorSize),
1158+
Value: int64(AnchorSize),
11591159
})
11601160
}
11611161

@@ -1164,7 +1164,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
11641164
if remoteOutput || numHTLCs > 0 {
11651165
commitTx.AddTxOut(&wire.TxOut{
11661166
PkScript: remoteAnchor.PkScript(),
1167-
Value: int64(anchorSize),
1167+
Value: int64(AnchorSize),
11681168
})
11691169
}
11701170
}
@@ -1189,7 +1189,7 @@ func CoopCloseBalance(chanType channeldb.ChannelType, isInitiator bool,
11891189
// Since the initiator's balance also is stored after subtracting the
11901190
// anchor values, add that back in case this was an anchor commitment.
11911191
if chanType.HasAnchors() {
1192-
initiatorDelta += 2 * anchorSize
1192+
initiatorDelta += 2 * AnchorSize
11931193
}
11941194

11951195
// The initiator will pay the full coop close fee, subtract that value

lnwallet/reservation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
265265
// addition to the two anchor outputs.
266266
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
267267
if req.CommitType.HasAnchors() {
268-
feeMSat += 2 * lnwire.NewMSatFromSatoshis(anchorSize)
268+
feeMSat += 2 * lnwire.NewMSatFromSatoshis(AnchorSize)
269269
}
270270

271271
// Used to cut down on verbosity.

lnwallet/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
254254
commitFee := calcStaticFee(chanType, 0)
255255
var anchorAmt btcutil.Amount
256256
if chanType.HasAnchors() {
257-
anchorAmt += 2 * anchorSize
257+
anchorAmt += 2 * AnchorSize
258258
}
259259

260260
aliceBalance := lnwire.NewMSatFromSatoshis(

lnwallet/transactions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ func createTestChannelsForVectors(tc *testContext, chanType channeldb.ChannelTyp
923923

924924
var anchorAmt btcutil.Amount
925925
if chanType.HasAnchors() {
926-
anchorAmt = 2 * anchorSize
926+
anchorAmt = 2 * AnchorSize
927927
}
928928

929929
remoteCommitTx, localCommitTx, err := CreateCommitmentTxns(

0 commit comments

Comments
 (0)