mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-09 01:32:09 +02:00
lnwallet: in NewChannelReservation ensure commit fees are payable
In this commit, we fix a bug introduced by the recent change of lnwire.MilliSatoshi to be an unsigned integer. After this change an integer underflow was left undetected, as a result we’ll now momentarily cast to a signed integer in order to ensure that both sides can pay the proper fee.
This commit is contained in:
@@ -157,6 +157,15 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
|||||||
ourBalance = pushMSat
|
ourBalance = pushMSat
|
||||||
theirBalance = capacityMSat - feeMSat - pushMSat
|
theirBalance = capacityMSat - feeMSat - pushMSat
|
||||||
initiator = false
|
initiator = false
|
||||||
|
|
||||||
|
// If the responder doesn't have enough funds to actually pay
|
||||||
|
// the fees, then we'll bail our early.
|
||||||
|
if int64(theirBalance) < 0 {
|
||||||
|
return nil, ErrFunderBalanceDust(
|
||||||
|
int64(commitFee), int64(theirBalance.ToSatoshis()),
|
||||||
|
int64(2*DefaultDustLimit()),
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO(roasbeef): need to rework fee structure in general and
|
// TODO(roasbeef): need to rework fee structure in general and
|
||||||
// also when we "unlock" dual funder within the daemon
|
// also when we "unlock" dual funder within the daemon
|
||||||
@@ -177,6 +186,15 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
initiator = true
|
initiator = true
|
||||||
|
|
||||||
|
// If we, the initiator don't have enough funds to actually pay
|
||||||
|
// the fees, then we'll exit with an error.
|
||||||
|
if int64(ourBalance) < 0 {
|
||||||
|
return nil, ErrFunderBalanceDust(
|
||||||
|
int64(commitFee), int64(ourBalance),
|
||||||
|
int64(2*DefaultDustLimit()),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're the initiator and our starting balance within the channel
|
// If we're the initiator and our starting balance within the channel
|
||||||
|
Reference in New Issue
Block a user