rpc: on chan close, fallback to default fee rate if fee estimate too low

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-12-16 16:31:57 -08:00
parent 84d7c7ee2c
commit 8411a5b8ce
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 10 additions and 1 deletions

View File

@ -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)
}