Skip to content

Commit cf2174f

Browse files
committed
lnwallet: export AnchorSize
1 parent 22a3988 commit cf2174f

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

lnwallet/channel.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7694,7 +7694,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
76947694
WitnessScript: anchorWitnessScript,
76957695
Output: &wire.TxOut{
76967696
PkScript: localAnchor.PkScript(),
7697-
Value: int64(anchorSize),
7697+
Value: int64(AnchorSize),
76987698
},
76997699
HashType: sweepSigHash(chanState.ChanType),
77007700
}
@@ -7706,7 +7706,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
77067706

77077707
//nolint:lll
77087708
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
7709-
localAnchor.PkScript(), int64(anchorSize),
7709+
localAnchor.PkScript(), int64(AnchorSize),
77107710
)
77117711

77127712
// For anchor outputs with taproot channels, the key desc is
@@ -8249,7 +8249,7 @@ func (lc *LightningChannel) LocalBalanceDust() bool {
82498249
// regain the stats allocated to the anchor outputs with the co-op
82508250
// close transaction.
82518251
if chanState.ChanType.HasAnchors() && chanState.IsInitiator {
8252-
localBalance += 2 * anchorSize
8252+
localBalance += 2 * AnchorSize
82538253
}
82548254

82558255
return localBalance <= chanState.LocalChanCfg.DustLimit
@@ -8269,7 +8269,7 @@ func (lc *LightningChannel) RemoteBalanceDust() bool {
82698269
// regain the stats allocated to the anchor outputs with the co-op
82708270
// close transaction.
82718271
if chanState.ChanType.HasAnchors() && !chanState.IsInitiator {
8272-
remoteBalance += 2 * anchorSize
8272+
remoteBalance += 2 * AnchorSize
82738273
}
82748274

82758275
return remoteBalance <= chanState.RemoteChanCfg.DustLimit

lnwallet/channel_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
706706
testCoopClose(t, &coopCloseTestCase{
707707
chanType: channeldb.SingleFunderTweaklessBit |
708708
channeldb.AnchorOutputsBit,
709-
anchorAmt: anchorSize * 2,
709+
anchorAmt: AnchorSize * 2,
710710
})
711711
})
712712
}
@@ -816,7 +816,7 @@ func TestForceClose(t *testing.T) {
816816
chanType: channeldb.SingleFunderTweaklessBit |
817817
channeldb.AnchorOutputsBit,
818818
expectedCommitWeight: input.AnchorCommitWeight,
819-
anchorAmt: anchorSize * 2,
819+
anchorAmt: AnchorSize * 2,
820820
})
821821
})
822822
t.Run("taproot", func(t *testing.T) {
@@ -825,7 +825,7 @@ func TestForceClose(t *testing.T) {
825825
channeldb.AnchorOutputsBit |
826826
channeldb.SimpleTaprootFeatureBit,
827827
expectedCommitWeight: input.TaprootCommitWeight,
828-
anchorAmt: anchorSize * 2,
828+
anchorAmt: AnchorSize * 2,
829829
})
830830
})
831831
}
@@ -911,7 +911,7 @@ func testForceClose(t *testing.T, testCase *forceCloseTestCase) {
911911
t.Fatal("commit tx not referenced by anchor res")
912912
}
913913
if anchorRes.AnchorSignDescriptor.Output.Value !=
914-
int64(anchorSize) {
914+
int64(AnchorSize) {
915915

916916
t.Fatal("unexpected anchor size")
917917
}

lnwallet/commitment.go

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

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

2323
// DefaultAnchorsCommitMaxFeeRateSatPerVByte is the default max fee rate in
2424
// sat/vbyte the initiator will use for anchor channels. This should be enough
@@ -942,7 +942,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
942942
if localOutput || numHTLCs > 0 {
943943
commitTx.AddTxOut(&wire.TxOut{
944944
PkScript: localAnchor.PkScript(),
945-
Value: int64(anchorSize),
945+
Value: int64(AnchorSize),
946946
})
947947
}
948948

@@ -951,7 +951,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
951951
if remoteOutput || numHTLCs > 0 {
952952
commitTx.AddTxOut(&wire.TxOut{
953953
PkScript: remoteAnchor.PkScript(),
954-
Value: int64(anchorSize),
954+
Value: int64(AnchorSize),
955955
})
956956
}
957957
}
@@ -976,7 +976,7 @@ func CoopCloseBalance(chanType channeldb.ChannelType, isInitiator bool,
976976
// Since the initiator's balance also is stored after subtracting the
977977
// anchor values, add that back in case this was an anchor commitment.
978978
if chanType.HasAnchors() {
979-
initiatorDelta += 2 * anchorSize
979+
initiatorDelta += 2 * AnchorSize
980980
}
981981

982982
// 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
@@ -261,7 +261,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
261261
// addition to the two anchor outputs.
262262
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
263263
if req.CommitType.HasAnchors() {
264-
feeMSat += 2 * lnwire.NewMSatFromSatoshis(anchorSize)
264+
feeMSat += 2 * lnwire.NewMSatFromSatoshis(AnchorSize)
265265
}
266266

267267
// Used to cut down on verbosity.

lnwallet/test_utils.go

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

264264
aliceBalance := lnwire.NewMSatFromSatoshis(

lnwallet/transactions_test.go

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

926926
var anchorAmt btcutil.Amount
927927
if chanType.HasAnchors() {
928-
anchorAmt = 2 * anchorSize
928+
anchorAmt = 2 * AnchorSize
929929
}
930930

931931
remoteCommitTx, localCommitTx, err := CreateCommitmentTxns(

0 commit comments

Comments
 (0)