lnwallet/channel: don't return feePerKw from computeView
Since the feerate is part of the computed view now, we don't have to pass the found feerate as a distinct parameter.
This commit is contained in:
parent
7e015258cd
commit
dadfcefc07
@ -2245,8 +2245,10 @@ func (lc *LightningChannel) fetchCommitmentView(remoteChain bool,
|
|||||||
// in order to update their commitment addition height, and to adjust
|
// in order to update their commitment addition height, and to adjust
|
||||||
// the balances on the commitment transaction accordingly.
|
// the balances on the commitment transaction accordingly.
|
||||||
htlcView := lc.fetchHTLCView(theirLogIndex, ourLogIndex)
|
htlcView := lc.fetchHTLCView(theirLogIndex, ourLogIndex)
|
||||||
ourBalance, theirBalance, _, filteredHTLCView, feePerKw :=
|
ourBalance, theirBalance, _, filteredHTLCView := lc.computeView(
|
||||||
lc.computeView(htlcView, remoteChain, true)
|
htlcView, remoteChain, true,
|
||||||
|
)
|
||||||
|
feePerKw := filteredHTLCView.feePerKw
|
||||||
|
|
||||||
// Determine how many current HTLCs are over the dust limit, and should
|
// Determine how many current HTLCs are over the dust limit, and should
|
||||||
// be counted for the purpose of fee calculation.
|
// be counted for the purpose of fee calculation.
|
||||||
@ -3543,7 +3545,7 @@ func ChanSyncMsg(c *channeldb.OpenChannel) (*lnwire.ChannelReestablish, error) {
|
|||||||
// HTLCs will be set to the next commitment height.
|
// HTLCs will be set to the next commitment height.
|
||||||
func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
|
func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
|
||||||
updateState bool) (lnwire.MilliSatoshi, lnwire.MilliSatoshi, int64,
|
updateState bool) (lnwire.MilliSatoshi, lnwire.MilliSatoshi, int64,
|
||||||
*htlcView, SatPerKWeight) {
|
*htlcView) {
|
||||||
|
|
||||||
commitChain := lc.localCommitChain
|
commitChain := lc.localCommitChain
|
||||||
dustLimit := lc.localChanCfg.DustLimit
|
dustLimit := lc.localChanCfg.DustLimit
|
||||||
@ -3607,7 +3609,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalCommitWeight := CommitWeight + totalHtlcWeight
|
totalCommitWeight := CommitWeight + totalHtlcWeight
|
||||||
return ourBalance, theirBalance, totalCommitWeight, filteredHTLCView, feePerKw
|
return ourBalance, theirBalance, totalCommitWeight, filteredHTLCView
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateCommitmentSanity is used to validate the current state of the
|
// validateCommitmentSanity is used to validate the current state of the
|
||||||
@ -3638,9 +3640,10 @@ func (lc *LightningChannel) validateCommitmentSanity(theirLogCounter,
|
|||||||
ourInitialBalance := commitChain.tip().ourBalance
|
ourInitialBalance := commitChain.tip().ourBalance
|
||||||
theirInitialBalance := commitChain.tip().theirBalance
|
theirInitialBalance := commitChain.tip().theirBalance
|
||||||
|
|
||||||
ourBalance, theirBalance, commitWeight, filteredView, feePerKw := lc.computeView(
|
ourBalance, theirBalance, commitWeight, filteredView := lc.computeView(
|
||||||
view, remoteChain, false,
|
view, remoteChain, false,
|
||||||
)
|
)
|
||||||
|
feePerKw := filteredView.feePerKw
|
||||||
|
|
||||||
// Calculate the commitment fee, and subtract it from the initiator's
|
// Calculate the commitment fee, and subtract it from the initiator's
|
||||||
// balance.
|
// balance.
|
||||||
@ -5898,12 +5901,12 @@ func (lc *LightningChannel) availableBalance() (lnwire.MilliSatoshi, int64) {
|
|||||||
lc.localUpdateLog.logIndex)
|
lc.localUpdateLog.logIndex)
|
||||||
|
|
||||||
// Then compute our current balance for that view.
|
// Then compute our current balance for that view.
|
||||||
ourBalance, _, commitWeight, _, feePerKw :=
|
ourBalance, _, commitWeight, filteredView :=
|
||||||
lc.computeView(htlcView, false, false)
|
lc.computeView(htlcView, false, false)
|
||||||
|
|
||||||
// If we are the channel initiator, we must remember to subtract the
|
// If we are the channel initiator, we must remember to subtract the
|
||||||
// commitment fee from our available balance.
|
// commitment fee from our available balance.
|
||||||
commitFee := feePerKw.FeeForWeight(commitWeight)
|
commitFee := filteredView.feePerKw.FeeForWeight(commitWeight)
|
||||||
if lc.channelState.IsInitiator {
|
if lc.channelState.IsInitiator {
|
||||||
ourBalance -= lnwire.NewMSatFromSatoshis(commitFee)
|
ourBalance -= lnwire.NewMSatFromSatoshis(commitFee)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user