lnwallet/reservation: add non-initiator balance check

If we are the initiator, we check that our starting balance after
subtracting fees are not less than two times the default dust limit.

This commit adds a similar check for the non-initiator case, checking
that the remote party has a starting balance of reasonable size.
This commit is contained in:
Johan T. Halseth 2020-03-06 16:11:48 +01:00
parent ad8e9f30c6
commit 8741b93723
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -213,6 +213,16 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
)
}
// Similarly we ensure their balance is reasonable if we are not the
// initiator.
if !initiator && theirBalance.ToSatoshis() <= 2*DefaultDustLimit() {
return nil, ErrFunderBalanceDust(
int64(commitFee),
int64(theirBalance.ToSatoshis()),
int64(2*DefaultDustLimit()),
)
}
// Next we'll set the channel type based on what we can ascertain about
// the balances/push amount within the channel.
var chanType channeldb.ChannelType