lnwallet: if the initiator is unable to pay fees, then consume their entire output
In this commit, we add logic to account for an edge case in the protocol. If they initiator if unable to pay the fees for a commitment, then their *entire* output is meant to go to fees. The recent change to properly interpret balances as unsigned integers (within the protocol) let to the discovery of this missed edge case.
This commit is contained in:
parent
19bc477b9a
commit
5f5e4554cb
@ -2142,10 +2142,19 @@ func (lc *LightningChannel) createCommitmentTx(c *commitment,
|
||||
|
||||
// Currently, within the protocol, the initiator always pays the fees.
|
||||
// So we'll subtract the fee amount from the balance of the current
|
||||
// initiator.
|
||||
if lc.channelState.IsInitiator {
|
||||
// initiator. If the initiator is unable to pay the fee fully, then
|
||||
// their entire output is consumed.
|
||||
switch {
|
||||
case lc.channelState.IsInitiator && commitFee > ourBalance.ToSatoshis():
|
||||
ourBalance = 0
|
||||
|
||||
case lc.channelState.IsInitiator:
|
||||
ourBalance -= lnwire.NewMSatFromSatoshis(commitFee)
|
||||
} else if !lc.channelState.IsInitiator {
|
||||
|
||||
case !lc.channelState.IsInitiator && commitFee > theirBalance.ToSatoshis():
|
||||
theirBalance = 0
|
||||
|
||||
case !lc.channelState.IsInitiator:
|
||||
theirBalance -= lnwire.NewMSatFromSatoshis(commitFee)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user