Skip to content

Commit fa61f26

Browse files
committed
lnwallet: export AnchorSize
1 parent 5e1dd2a commit fa61f26

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
@@ -8575,7 +8575,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
85758575
WitnessScript: anchorWitnessScript,
85768576
Output: &wire.TxOut{
85778577
PkScript: localAnchor.PkScript(),
8578-
Value: int64(anchorSize),
8578+
Value: int64(AnchorSize),
85798579
},
85808580
HashType: sweepSigHash(chanState.ChanType),
85818581
}
@@ -8587,7 +8587,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
85878587

85888588
//nolint:lll
85898589
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
8590-
localAnchor.PkScript(), int64(anchorSize),
8590+
localAnchor.PkScript(), int64(AnchorSize),
85918591
)
85928592

85938593
// For anchor outputs with taproot channels, the key desc is
@@ -9080,7 +9080,7 @@ func (lc *LightningChannel) LocalBalanceDust() bool {
90809080
// regain the stats allocated to the anchor outputs with the co-op
90819081
// close transaction.
90829082
if chanState.ChanType.HasAnchors() && chanState.IsInitiator {
9083-
localBalance += 2 * anchorSize
9083+
localBalance += 2 * AnchorSize
90849084
}
90859085

90869086
return localBalance <= chanState.LocalChanCfg.DustLimit
@@ -9100,7 +9100,7 @@ func (lc *LightningChannel) RemoteBalanceDust() bool {
91009100
// regain the stats allocated to the anchor outputs with the co-op
91019101
// close transaction.
91029102
if chanState.ChanType.HasAnchors() && !chanState.IsInitiator {
9103-
remoteBalance += 2 * anchorSize
9103+
remoteBalance += 2 * AnchorSize
91049104
}
91059105

91069106
return remoteBalance <= chanState.RemoteChanCfg.DustLimit

lnwallet/channel_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
713713
testCoopClose(t, &coopCloseTestCase{
714714
chanType: channeldb.SingleFunderTweaklessBit |
715715
channeldb.AnchorOutputsBit,
716-
anchorAmt: anchorSize * 2,
716+
anchorAmt: AnchorSize * 2,
717717
})
718718
})
719719
}
@@ -823,7 +823,7 @@ func TestForceClose(t *testing.T) {
823823
chanType: channeldb.SingleFunderTweaklessBit |
824824
channeldb.AnchorOutputsBit,
825825
expectedCommitWeight: input.AnchorCommitWeight,
826-
anchorAmt: anchorSize * 2,
826+
anchorAmt: AnchorSize * 2,
827827
})
828828
})
829829
t.Run("taproot", func(t *testing.T) {
@@ -832,7 +832,7 @@ func TestForceClose(t *testing.T) {
832832
channeldb.AnchorOutputsBit |
833833
channeldb.SimpleTaprootFeatureBit,
834834
expectedCommitWeight: input.TaprootCommitWeight,
835-
anchorAmt: anchorSize * 2,
835+
anchorAmt: AnchorSize * 2,
836836
})
837837
})
838838
t.Run("taproot with tapscript root", func(t *testing.T) {
@@ -842,7 +842,7 @@ func TestForceClose(t *testing.T) {
842842
channeldb.SimpleTaprootFeatureBit |
843843
channeldb.TapscriptRootBit,
844844
expectedCommitWeight: input.TaprootCommitWeight,
845-
anchorAmt: anchorSize * 2,
845+
anchorAmt: AnchorSize * 2,
846846
})
847847
})
848848
}
@@ -928,7 +928,7 @@ func testForceClose(t *testing.T, testCase *forceCloseTestCase) {
928928
t.Fatal("commit tx not referenced by anchor res")
929929
}
930930
if anchorRes.AnchorSignDescriptor.Output.Value !=
931-
int64(anchorSize) {
931+
int64(AnchorSize) {
932932

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

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
@@ -1184,7 +1184,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
11841184
if localOutput || numHTLCs > 0 {
11851185
commitTx.AddTxOut(&wire.TxOut{
11861186
PkScript: localAnchor.PkScript(),
1187-
Value: int64(anchorSize),
1187+
Value: int64(AnchorSize),
11881188
})
11891189
}
11901190

@@ -1193,7 +1193,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
11931193
if remoteOutput || numHTLCs > 0 {
11941194
commitTx.AddTxOut(&wire.TxOut{
11951195
PkScript: remoteAnchor.PkScript(),
1196-
Value: int64(anchorSize),
1196+
Value: int64(AnchorSize),
11971197
})
11981198
}
11991199
}
@@ -1218,7 +1218,7 @@ func CoopCloseBalance(chanType channeldb.ChannelType, isInitiator bool,
12181218
// Since the initiator's balance also is stored after subtracting the
12191219
// anchor values, add that back in case this was an anchor commitment.
12201220
if chanType.HasAnchors() {
1221-
initiatorDelta += 2 * anchorSize
1221+
initiatorDelta += 2 * AnchorSize
12221222
}
12231223

12241224
// 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
@@ -268,7 +268,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
268268
// addition to the two anchor outputs.
269269
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
270270
if req.CommitType.HasAnchors() {
271-
feeMSat += 2 * lnwire.NewMSatFromSatoshis(anchorSize)
271+
feeMSat += 2 * lnwire.NewMSatFromSatoshis(AnchorSize)
272272
}
273273

274274
// 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)