input: remove duplicate commit weight constant
This commit is contained in:
parent
a56ed72bd7
commit
3711597fef
@ -1973,7 +1973,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
htlcFee := lnwire.NewMSatFromSatoshis(
|
||||
feePerKw.FeeForWeight(input.HtlcWeight),
|
||||
feePerKw.FeeForWeight(input.HTLCWeight),
|
||||
)
|
||||
|
||||
// The starting bandwidth of the channel should be exactly the amount
|
||||
@ -2462,7 +2462,7 @@ func TestChannelLinkBandwidthConsistencyOverflow(t *testing.T) {
|
||||
|
||||
// TODO(roasbeef): increase sleep
|
||||
time.Sleep(time.Second * 1)
|
||||
commitWeight := input.CommitWeight + input.HtlcWeight*numHTLCs
|
||||
commitWeight := int64(input.CommitWeight + input.HTLCWeight*numHTLCs)
|
||||
htlcFee := lnwire.NewMSatFromSatoshis(
|
||||
feePerKw.FeeForWeight(commitWeight),
|
||||
)
|
||||
@ -2646,7 +2646,7 @@ func TestChannelLinkTrimCircuitsPending(t *testing.T) {
|
||||
|
||||
defaultCommitFee := alice.channel.StateSnapshot().CommitFee
|
||||
htlcFee := lnwire.NewMSatFromSatoshis(
|
||||
feePerKw.FeeForWeight(input.HtlcWeight),
|
||||
feePerKw.FeeForWeight(input.HTLCWeight),
|
||||
)
|
||||
|
||||
// The starting bandwidth of the channel should be exactly the amount
|
||||
@ -2925,7 +2925,7 @@ func TestChannelLinkTrimCircuitsNoCommit(t *testing.T) {
|
||||
|
||||
defaultCommitFee := alice.channel.StateSnapshot().CommitFee
|
||||
htlcFee := lnwire.NewMSatFromSatoshis(
|
||||
feePerKw.FeeForWeight(input.HtlcWeight),
|
||||
feePerKw.FeeForWeight(input.HTLCWeight),
|
||||
)
|
||||
|
||||
// The starting bandwidth of the channel should be exactly the amount
|
||||
@ -3181,7 +3181,7 @@ func TestChannelLinkBandwidthChanReserve(t *testing.T) {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
htlcFee := lnwire.NewMSatFromSatoshis(
|
||||
feePerKw.FeeForWeight(input.HtlcWeight),
|
||||
feePerKw.FeeForWeight(input.HTLCWeight),
|
||||
)
|
||||
|
||||
// The starting bandwidth of the channel should be exactly the amount
|
||||
|
@ -5,15 +5,6 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
const (
|
||||
// CommitWeight is the weight of the base commitment transaction which
|
||||
// includes: one p2wsh input, out p2wkh output, and one p2wsh output.
|
||||
CommitWeight int64 = 724
|
||||
|
||||
// HtlcWeight is the weight of an HTLC output.
|
||||
HtlcWeight int64 = 172
|
||||
)
|
||||
|
||||
const (
|
||||
// witnessScaleFactor determines the level of "discount" witness data
|
||||
// receives compared to "base" data. A scale factor of 4, denotes that
|
||||
@ -168,6 +159,9 @@ const (
|
||||
// WitnessCommitmentTxWeight 224 weight
|
||||
WitnessCommitmentTxWeight = WitnessHeaderSize + WitnessSize
|
||||
|
||||
// CommitWeight 724 weight
|
||||
CommitWeight = BaseCommitmentTxWeight + WitnessCommitmentTxWeight
|
||||
|
||||
// HTLCWeight 172 weight
|
||||
HTLCWeight = witnessScaleFactor * HTLCSize
|
||||
|
||||
|
@ -3450,7 +3450,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
|
||||
continue
|
||||
}
|
||||
|
||||
totalHtlcWeight += input.HtlcWeight
|
||||
totalHtlcWeight += input.HTLCWeight
|
||||
}
|
||||
for _, htlc := range filteredHTLCView.theirUpdates {
|
||||
if htlcIsDust(!remoteChain, !remoteChain, feePerKw,
|
||||
@ -3458,7 +3458,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
|
||||
continue
|
||||
}
|
||||
|
||||
totalHtlcWeight += input.HtlcWeight
|
||||
totalHtlcWeight += input.HTLCWeight
|
||||
}
|
||||
|
||||
totalCommitWeight := input.CommitWeight + totalHtlcWeight
|
||||
|
@ -600,7 +600,7 @@ func TestForceClose(t *testing.T) {
|
||||
|
||||
// Factoring in the fee rate, Alice's amount should properly reflect
|
||||
// that we've added two additional HTLC to the commitment transaction.
|
||||
totalCommitWeight := input.CommitWeight + (input.HtlcWeight * 2)
|
||||
totalCommitWeight := int64(input.CommitWeight + (input.HTLCWeight * 2))
|
||||
feePerKw := chainfee.SatPerKWeight(
|
||||
aliceChannel.channelState.LocalCommitment.FeePerKw,
|
||||
)
|
||||
|
@ -287,7 +287,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
|
||||
// on its total weight. Once we have the total weight, we'll multiply
|
||||
// by the current fee-per-kw, then divide by 1000 to get the proper
|
||||
// fee.
|
||||
totalCommitWeight := input.CommitWeight + (input.HtlcWeight * numHTLCs)
|
||||
totalCommitWeight := input.CommitWeight + (input.HTLCWeight * numHTLCs)
|
||||
|
||||
// With the weight known, we can now calculate the commitment fee,
|
||||
// ensuring that we account for any dust outputs trimmed above.
|
||||
|
Loading…
Reference in New Issue
Block a user