From 9e9c48fcdd24d34e1ec6c4b7e1d9a4921902cdbf Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 3 Mar 2021 10:44:42 +0200 Subject: [PATCH] rpc: use default if conf-target is not set This commit uses the new coop-close-target-confs value as the default to use for a nodes self initiated channel closures if the conf-target flag for the channel closure is not set. The defaults for both these options is 6 so this shouldnt change current behaviour. --- cmd/lncli/commands.go | 4 +++- rpcserver.go | 9 ++++++++- sample-lnd.conf | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 61fbca82..d7a81bd4 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -669,7 +669,9 @@ var closeChannelCommand = cli.Command{ Name: "conf_target", Usage: "(optional) the number of blocks that the " + "transaction *should* confirm in, will be " + - "used for fee estimation", + "used for fee estimation. If not set, " + + "then the conf-target value set in the main " + + "lnd config will be used.", }, cli.Int64Flag{ Name: "sat_per_byte", diff --git a/rpcserver.go b/rpcserver.go index d8883351..d1acfb77 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2317,6 +2317,13 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest, "is offline (try force closing it instead): %v", err) } + // If conf-target is not set then use the conf-target used for + // co-op closes that are initiated by the remote peer. + targetConf := uint32(in.TargetConf) + if targetConf == 0 { + targetConf = r.cfg.CoopCloseTargetConfs + } + // Based on the passed fee related parameters, we'll determine // an appropriate fee rate for the cooperative closure // transaction. @@ -2325,7 +2332,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest, ).FeePerKWeight() feeRate, err := sweep.DetermineFeePerKw( r.server.cc.FeeEstimator, sweep.FeePreference{ - ConfTarget: uint32(in.TargetConf), + ConfTarget: targetConf, FeeRate: satPerKw, }, ) diff --git a/sample-lnd.conf b/sample-lnd.conf index 9cddfcb5..5a94a3af 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -254,7 +254,9 @@ ; The target number of blocks in which a cooperative close initiated by a remote ; peer should be confirmed. This target is used to estimate the starting fee -; rate that will be used during fee negotiation with the peer. +; rate that will be used during fee negotiation with the peer. This target is +; is also used for cooperative closes initiated locally if the --conf_target +; for the channel closure is not set. ; coop-close-target-confs=10 ; The default max_htlc applied when opening or accepting channels. This value