From fb523ff5ac856454f393a43084186510a1d4f642 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 16 Jan 2017 20:46:32 -0800 Subject: [PATCH] rpcserver: add a min channel size for funding requests This commit adds a soft-limit for the minimum allowed channel size. Without this limit a user may inadvertently create an invalid or unspendable output due to the hard coded fees in a few areas of the codebase. This is a temporary measure, and will be removed once we add dynamic fees into the mix. --- rpcserver.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index eb6c3ca3..a8d11d06 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -245,6 +245,19 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest, "state must be below the local funding amount") } + const minChannelSize = btcutil.Amount(6000) + + // Restrict the size of the channel we'll actually open. Atm, we + // require the amount to be above 6k satoahis s we currently hard-coded + // a 5k satoshi fee in several areas. As a result 6k sat is the min + // channnel size that allows us to safely sit above the dust threshold + // after fees are applied + // TODO(roasbeef): remove after dynamic fees are in + if localFundingAmt > minChannelSize { + return fmt.Errorf("channel is too small, the minimum channel "+ + "size is: %v (6k sat)", minChannelSize) + } + var ( nodepubKey *btcec.PublicKey err error