lnwallet: export AnchorSize
This commit is contained in:
6 files changed
+16
-16
No files matched your search
+4
-4
@@ -7694,7 +7694,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
|
|||||||
WitnessScript: anchorWitnessScript,
|
WitnessScript: anchorWitnessScript,
|
||||||
Output: &wire.TxOut{
|
Output: &wire.TxOut{
|
||||||
PkScript: localAnchor.PkScript(),
|
PkScript: localAnchor.PkScript(),
|
||||||
Value: int64(anchorSize),
|
Value: int64(AnchorSize),
|
||||||
},
|
},
|
||||||
HashType: sweepSigHash(chanState.ChanType),
|
HashType: sweepSigHash(chanState.ChanType),
|
||||||
}
|
}
|
||||||
@@ -7706,7 +7706,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
|
|||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
|
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
|
||||||
localAnchor.PkScript(), int64(anchorSize),
|
localAnchor.PkScript(), int64(AnchorSize),
|
||||||
)
|
)
|
||||||
|
|
||||||
// For anchor outputs with taproot channels, the key desc is
|
// For anchor outputs with taproot channels, the key desc is
|
||||||
@@ -8249,7 +8249,7 @@ func (lc *LightningChannel) LocalBalanceDust() bool {
|
|||||||
// regain the stats allocated to the anchor outputs with the co-op
|
// regain the stats allocated to the anchor outputs with the co-op
|
||||||
// close transaction.
|
// close transaction.
|
||||||
if chanState.ChanType.HasAnchors() && chanState.IsInitiator {
|
if chanState.ChanType.HasAnchors() && chanState.IsInitiator {
|
||||||
localBalance += 2 * anchorSize
|
localBalance += 2 * AnchorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
return localBalance <= chanState.LocalChanCfg.DustLimit
|
return localBalance <= chanState.LocalChanCfg.DustLimit
|
||||||
@@ -8269,7 +8269,7 @@ func (lc *LightningChannel) RemoteBalanceDust() bool {
|
|||||||
// regain the stats allocated to the anchor outputs with the co-op
|
// regain the stats allocated to the anchor outputs with the co-op
|
||||||
// close transaction.
|
// close transaction.
|
||||||
if chanState.ChanType.HasAnchors() && !chanState.IsInitiator {
|
if chanState.ChanType.HasAnchors() && !chanState.IsInitiator {
|
||||||
remoteBalance += 2 * anchorSize
|
remoteBalance += 2 * AnchorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
return remoteBalance <= chanState.RemoteChanCfg.DustLimit
|
return remoteBalance <= chanState.RemoteChanCfg.DustLimit
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
|
|||||||
testCoopClose(t, &coopCloseTestCase{
|
testCoopClose(t, &coopCloseTestCase{
|
||||||
chanType: channeldb.SingleFunderTweaklessBit |
|
chanType: channeldb.SingleFunderTweaklessBit |
|
||||||
channeldb.AnchorOutputsBit,
|
channeldb.AnchorOutputsBit,
|
||||||
anchorAmt: anchorSize * 2,
|
anchorAmt: AnchorSize * 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -816,7 +816,7 @@ func TestForceClose(t *testing.T) {
|
|||||||
chanType: channeldb.SingleFunderTweaklessBit |
|
chanType: channeldb.SingleFunderTweaklessBit |
|
||||||
channeldb.AnchorOutputsBit,
|
channeldb.AnchorOutputsBit,
|
||||||
expectedCommitWeight: input.AnchorCommitWeight,
|
expectedCommitWeight: input.AnchorCommitWeight,
|
||||||
anchorAmt: anchorSize * 2,
|
anchorAmt: AnchorSize * 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("taproot", func(t *testing.T) {
|
t.Run("taproot", func(t *testing.T) {
|
||||||
@@ -825,7 +825,7 @@ func TestForceClose(t *testing.T) {
|
|||||||
channeldb.AnchorOutputsBit |
|
channeldb.AnchorOutputsBit |
|
||||||
channeldb.SimpleTaprootFeatureBit,
|
channeldb.SimpleTaprootFeatureBit,
|
||||||
expectedCommitWeight: input.TaprootCommitWeight,
|
expectedCommitWeight: input.TaprootCommitWeight,
|
||||||
anchorAmt: anchorSize * 2,
|
anchorAmt: AnchorSize * 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -911,7 +911,7 @@ func testForceClose(t *testing.T, testCase *forceCloseTestCase) {
|
|||||||
t.Fatal("commit tx not referenced by anchor res")
|
t.Fatal("commit tx not referenced by anchor res")
|
||||||
}
|
}
|
||||||
if anchorRes.AnchorSignDescriptor.Output.Value !=
|
if anchorRes.AnchorSignDescriptor.Output.Value !=
|
||||||
int64(anchorSize) {
|
int64(AnchorSize) {
|
||||||
|
|
||||||
t.Fatal("unexpected anchor size")
|
t.Fatal("unexpected anchor size")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// anchorSize is the constant anchor output size.
|
// AnchorSize is the constant anchor output size.
|
||||||
const anchorSize = btcutil.Amount(330)
|
const AnchorSize = btcutil.Amount(330)
|
||||||
|
|
||||||
// DefaultAnchorsCommitMaxFeeRateSatPerVByte is the default max fee rate in
|
// DefaultAnchorsCommitMaxFeeRateSatPerVByte is the default max fee rate in
|
||||||
// sat/vbyte the initiator will use for anchor channels. This should be enough
|
// sat/vbyte the initiator will use for anchor channels. This should be enough
|
||||||
@@ -942,7 +942,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
|
|||||||
if localOutput || numHTLCs > 0 {
|
if localOutput || numHTLCs > 0 {
|
||||||
commitTx.AddTxOut(&wire.TxOut{
|
commitTx.AddTxOut(&wire.TxOut{
|
||||||
PkScript: localAnchor.PkScript(),
|
PkScript: localAnchor.PkScript(),
|
||||||
Value: int64(anchorSize),
|
Value: int64(AnchorSize),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,7 +951,7 @@ func CreateCommitTx(chanType channeldb.ChannelType,
|
|||||||
if remoteOutput || numHTLCs > 0 {
|
if remoteOutput || numHTLCs > 0 {
|
||||||
commitTx.AddTxOut(&wire.TxOut{
|
commitTx.AddTxOut(&wire.TxOut{
|
||||||
PkScript: remoteAnchor.PkScript(),
|
PkScript: remoteAnchor.PkScript(),
|
||||||
Value: int64(anchorSize),
|
Value: int64(AnchorSize),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -976,7 +976,7 @@ func CoopCloseBalance(chanType channeldb.ChannelType, isInitiator bool,
|
|||||||
// Since the initiator's balance also is stored after subtracting the
|
// Since the initiator's balance also is stored after subtracting the
|
||||||
// anchor values, add that back in case this was an anchor commitment.
|
// anchor values, add that back in case this was an anchor commitment.
|
||||||
if chanType.HasAnchors() {
|
if chanType.HasAnchors() {
|
||||||
initiatorDelta += 2 * anchorSize
|
initiatorDelta += 2 * AnchorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// The initiator will pay the full coop close fee, subtract that value
|
// The initiator will pay the full coop close fee, subtract that value
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||||||
// addition to the two anchor outputs.
|
// addition to the two anchor outputs.
|
||||||
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
|
feeMSat := lnwire.NewMSatFromSatoshis(commitFee)
|
||||||
if req.CommitType.HasAnchors() {
|
if req.CommitType.HasAnchors() {
|
||||||
feeMSat += 2 * lnwire.NewMSatFromSatoshis(anchorSize)
|
feeMSat += 2 * lnwire.NewMSatFromSatoshis(AnchorSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to cut down on verbosity.
|
// Used to cut down on verbosity.
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
|
|||||||
commitFee := calcStaticFee(chanType, 0)
|
commitFee := calcStaticFee(chanType, 0)
|
||||||
var anchorAmt btcutil.Amount
|
var anchorAmt btcutil.Amount
|
||||||
if chanType.HasAnchors() {
|
if chanType.HasAnchors() {
|
||||||
anchorAmt += 2 * anchorSize
|
anchorAmt += 2 * AnchorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceBalance := lnwire.NewMSatFromSatoshis(
|
aliceBalance := lnwire.NewMSatFromSatoshis(
|
||||||
|
|||||||
@@ -925,7 +925,7 @@ func createTestChannelsForVectors(tc *testContext, chanType channeldb.ChannelTyp
|
|||||||
|
|
||||||
var anchorAmt btcutil.Amount
|
var anchorAmt btcutil.Amount
|
||||||
if chanType.HasAnchors() {
|
if chanType.HasAnchors() {
|
||||||
anchorAmt = 2 * anchorSize
|
anchorAmt = 2 * AnchorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteCommitTx, localCommitTx, err := CreateCommitmentTxns(
|
remoteCommitTx, localCommitTx, err := CreateCommitmentTxns(
|
||||||
|
|||||||
Reference in new issue
Block a user