mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
lnwallet: modify CoopCloseBalance to not depend on chan commit
This commit is contained in:
parent
e536cfad0f
commit
8b97d4f833
@ -7781,7 +7781,10 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
|
||||
// during the channel closing process.
|
||||
ourBalance, theirBalance, err := CoopCloseBalance(
|
||||
lc.channelState.ChanType, lc.channelState.IsInitiator,
|
||||
proposedFee, lc.channelState.LocalCommitment,
|
||||
proposedFee,
|
||||
lc.channelState.LocalCommitment.LocalBalance.ToSatoshis(),
|
||||
lc.channelState.LocalCommitment.RemoteBalance.ToSatoshis(),
|
||||
lc.channelState.LocalCommitment.CommitFee,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, 0, err
|
||||
@ -7879,7 +7882,10 @@ func (lc *LightningChannel) CompleteCooperativeClose(
|
||||
// Get the final balances after subtracting the proposed fee.
|
||||
ourBalance, theirBalance, err := CoopCloseBalance(
|
||||
lc.channelState.ChanType, lc.channelState.IsInitiator,
|
||||
proposedFee, lc.channelState.LocalCommitment,
|
||||
proposedFee,
|
||||
lc.channelState.LocalCommitment.LocalBalance.ToSatoshis(),
|
||||
lc.channelState.LocalCommitment.RemoteBalance.ToSatoshis(),
|
||||
lc.channelState.LocalCommitment.CommitFee,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
|
@ -1033,16 +1033,12 @@ func CreateCommitTx(chanType channeldb.ChannelType,
|
||||
// CoopCloseBalance returns the final balances that should be used to create
|
||||
// the cooperative close tx, given the channel type and transaction fee.
|
||||
func CoopCloseBalance(chanType channeldb.ChannelType, isInitiator bool,
|
||||
coopCloseFee btcutil.Amount, localCommit channeldb.ChannelCommitment) (
|
||||
btcutil.Amount, btcutil.Amount, error) {
|
||||
|
||||
// Get both parties' balances from the latest commitment.
|
||||
ourBalance := localCommit.LocalBalance.ToSatoshis()
|
||||
theirBalance := localCommit.RemoteBalance.ToSatoshis()
|
||||
coopCloseFee, ourBalance, theirBalance,
|
||||
commitFee btcutil.Amount) (btcutil.Amount, btcutil.Amount, error) {
|
||||
|
||||
// We'll make sure we account for the complete balance by adding the
|
||||
// current dangling commitment fee to the balance of the initiator.
|
||||
initiatorDelta := localCommit.CommitFee
|
||||
initiatorDelta := commitFee
|
||||
|
||||
// Since the initiator's balance also is stored after subtracting the
|
||||
// anchor values, add that back in case this was an anchor commitment.
|
||||
|
Loading…
x
Reference in New Issue
Block a user