lnwallet: export HtlcWeight and CommitWeight publicly

This commit is contained in:
Olaoluwa Osuntokun 2017-11-09 22:15:21 -08:00
parent b1a6b877ce
commit 145cd0b2b6
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
4 changed files with 11 additions and 5 deletions

View File

@ -1972,7 +1972,7 @@ func (lc *LightningChannel) createCommitmentTx(c *commitment,
// 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 := commitWeight + (htlcWeight * numHTLCs)
totalCommitWeight := CommitWeight + (HtlcWeight * numHTLCs)
// With the weight known, we can now calculate the commitment fee,
// ensuring that we account for any dust outputs trimmed above.

View File

@ -144,7 +144,7 @@ func NewChannelReservation(capacity, fundingAmt, feePerKw btcutil.Amount,
initiator bool
)
commitFee := btcutil.Amount((int64(feePerKw) * commitWeight) / 1000)
commitFee := btcutil.Amount((int64(feePerKw) * CommitWeight) / 1000)
fundingMSat := lnwire.NewMSatFromSatoshis(fundingAmt)
capacityMSat := lnwire.NewMSatFromSatoshis(capacity)

View File

@ -5,6 +5,15 @@ import (
"github.com/roasbeef/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

View File

@ -39,9 +39,6 @@ const (
// TODO(roasbeef): should instead be child to make room for future
// rotations, etc.
identityKeyIndex = hdkeychain.HardenedKeyStart + 2
commitWeight int64 = 724
htlcWeight int64 = 172
)
var (