lnwallet: disallow creation of channels < 2x dust limit

Fixes #633.
This commit is contained in:
Olaoluwa Osuntokun 2018-01-28 15:11:13 -08:00
parent 87742ce861
commit 3036fc0181

@ -184,11 +184,11 @@ func NewChannelReservation(capacity, fundingAmt, commitFeePerKw btcutil.Amount,
} }
// If we're the initiator and our starting balance within the channel // If we're the initiator and our starting balance within the channel
// after we take account of fees is below dust, then we'll reject this // after we take account of fees is below 2x the dust limit, then we'll
// channel creation request. // reject this channel creation request.
// //
// TODO(roasbeef): reject if 30% goes to fees? dust channel // TODO(roasbeef): reject if 30% goes to fees? dust channel
if initiator && ourBalance.ToSatoshis() <= DefaultDustLimit() { if initiator && ourBalance.ToSatoshis() <= 2*DefaultDustLimit() {
return nil, fmt.Errorf("unable to init reservation, with "+ return nil, fmt.Errorf("unable to init reservation, with "+
"fee=%v sat/kw, local output is too small: %v sat", "fee=%v sat/kw, local output is too small: %v sat",
int64(commitFee), int64(ourBalance.ToSatoshis())) int64(commitFee), int64(ourBalance.ToSatoshis()))