From 8411a5b8ce2a8c953876375160cd8399cf16147a Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 16 Dec 2017 16:31:57 -0800 Subject: [PATCH] rpc: on chan close, fallback to default fee rate if fee estimate too low MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On testate as times the fee estimation can swing widely. As we currently don’t yet use vsize everywhere internally, we’re forced to manually scale to weight for the moment. If the returned fee rate is too low, then it can cause our estimate to go to zero. This also has the effect of meaning that the chanCloser doesn’t currently advance if the initial starting fee is zero. --- rpcserver.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rpcserver.go b/rpcserver.go index d7bf332c..f009b038 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -919,12 +919,21 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest, // When crating commitment transaction, or closure // transactions, we typically deal in fees per-kw, so we'll // convert now before passing the close request to the switch. - feePerKw := (feePerByte / blockchain.WitnessScaleFactor) * 1000 + feePerWeight := (feePerByte / blockchain.WitnessScaleFactor) + if feePerWeight == 0 { + // If the fee rate returned isn't usable, then we'll + // fall back to an lax fee estimate. + feePerWeight, err = r.server.cc.feeEstimator.EstimateFeePerWeight(6) + if err != nil { + return err + } + } // Otherwise, the caller has requested a regular interactive // cooperative channel closure. So we'll forward the request to // the htlc switch which will handle the negotiation and // broadcast details. + feePerKw := feePerWeight * 1000 updateChan, errChan = r.server.htlcSwitch.CloseLink(chanPoint, htlcswitch.CloseRegular, feePerKw) }