multi: allow setting target confs for co-op close

This commit adds a new config option: "--coop-close-target-confs"
which allows a user to override the default target confirmations of 6
that is used to estimate a fee rate to use during a co-op closure
initiated by a remote peer.
This commit is contained in:
Elle Mouton 2021-03-02 14:11:10 +02:00
parent 660d37a335
commit 3b412ce50f
4 changed files with 24 additions and 3 deletions

@ -89,6 +89,13 @@ const (
defaultAlias = "" defaultAlias = ""
defaultColor = "#3399FF" defaultColor = "#3399FF"
// defaultCoopCloseTargetConfs is the default confirmation target
// that will be used to estimate a fee rate to use during a
// cooperative channel closure initiated by a remote peer. By default
// we'll set this to a lax value since we weren't the ones that
// initiated the channel closure.
defaultCoopCloseTargetConfs = 6
// defaultHostSampleInterval is the default amount of time that the // defaultHostSampleInterval is the default amount of time that the
// HostAnnouncer will wait between DNS resolutions to check if the // HostAnnouncer will wait between DNS resolutions to check if the
// backing IP of a host has changed. // backing IP of a host has changed.
@ -273,6 +280,7 @@ type Config struct {
Color string `long:"color" description:"The color of the node in hex format (i.e. '#3399FF'). Used to customize node appearance in intelligence services"` Color string `long:"color" description:"The color of the node in hex format (i.e. '#3399FF'). Used to customize node appearance in intelligence services"`
MinChanSize int64 `long:"minchansize" description:"The smallest channel size (in satoshis) that we should accept. Incoming channels smaller than this will be rejected"` MinChanSize int64 `long:"minchansize" description:"The smallest channel size (in satoshis) that we should accept. Incoming channels smaller than this will be rejected"`
MaxChanSize int64 `long:"maxchansize" description:"The largest channel size (in satoshis) that we should accept. Incoming channels larger than this will be rejected"` MaxChanSize int64 `long:"maxchansize" description:"The largest channel size (in satoshis) that we should accept. Incoming channels larger than this will be rejected"`
CoopCloseTargetConfs uint32 `long:"coop-close-target-confs" description:"The target number of blocks that a cooperative channel close transaction should confirm in. This is used to estimate the fee to use as the lower bound during fee negotiation for the channel closure."`
DefaultRemoteMaxHtlcs uint16 `long:"default-remote-max-htlcs" description:"The default max_htlc applied when opening or accepting channels. This value limits the number of concurrent HTLCs that the remote party can add to the commitment. The maximum possible value is 483."` DefaultRemoteMaxHtlcs uint16 `long:"default-remote-max-htlcs" description:"The default max_htlc applied when opening or accepting channels. This value limits the number of concurrent HTLCs that the remote party can add to the commitment. The maximum possible value is 483."`
@ -434,6 +442,7 @@ func DefaultConfig() Config {
Color: defaultColor, Color: defaultColor,
MinChanSize: int64(funding.MinChanFundingSize), MinChanSize: int64(funding.MinChanFundingSize),
MaxChanSize: int64(0), MaxChanSize: int64(0),
CoopCloseTargetConfs: defaultCoopCloseTargetConfs,
DefaultRemoteMaxHtlcs: defaultRemoteMaxHtlcs, DefaultRemoteMaxHtlcs: defaultRemoteMaxHtlcs,
NumGraphSyncPeers: defaultMinPeers, NumGraphSyncPeers: defaultMinPeers,
HistoricalSyncInterval: discovery.DefaultHistoricalSyncInterval, HistoricalSyncInterval: discovery.DefaultHistoricalSyncInterval,

@ -298,6 +298,11 @@ type Config struct {
// initiator for anchor channel commitments. // initiator for anchor channel commitments.
MaxAnchorsCommitFeeRate chainfee.SatPerKWeight MaxAnchorsCommitFeeRate chainfee.SatPerKWeight
// CoopCloseTargetConfs is the confirmation target that will be used
// to estimate the fee rate to use during a cooperative channel
// closure initiated by the remote peer.
CoopCloseTargetConfs uint32
// ServerPubKey is the serialized, compressed public key of our lnd node. // ServerPubKey is the serialized, compressed public key of our lnd node.
// It is used to determine which policy (channel edge) to pass to the // It is used to determine which policy (channel edge) to pass to the
// ChannelLink. // ChannelLink.
@ -2340,9 +2345,10 @@ func (p *Brontide) fetchActiveChanCloser(chanID lnwire.ChannelID) (
} }
// In order to begin fee negotiations, we'll first compute our // In order to begin fee negotiations, we'll first compute our
// target ideal fee-per-kw. We'll set this to a lax value, as // target ideal fee-per-kw.
// we weren't the ones that initiated the channel closure. feePerKw, err := p.cfg.FeeEstimator.EstimateFeePerKW(
feePerKw, err := p.cfg.FeeEstimator.EstimateFeePerKW(6) p.cfg.CoopCloseTargetConfs,
)
if err != nil { if err != nil {
peerLog.Errorf("unable to query fee estimator: %v", err) peerLog.Errorf("unable to query fee estimator: %v", err)

@ -252,6 +252,11 @@
; to better align with your risk tolerance ; to better align with your risk tolerance
; maxchansize= ; maxchansize=
; 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.
; coop-close-target-confs=10
; The default max_htlc applied when opening or accepting channels. This value ; The default max_htlc applied when opening or accepting channels. This value
; limits the number of concurrent HTLCs that the remote party can add to the ; limits the number of concurrent HTLCs that the remote party can add to the
; commitment. The maximum possible value is 483. ; commitment. The maximum possible value is 483.

@ -3129,6 +3129,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
UnsafeReplay: s.cfg.UnsafeReplay, UnsafeReplay: s.cfg.UnsafeReplay,
MaxOutgoingCltvExpiry: s.cfg.MaxOutgoingCltvExpiry, MaxOutgoingCltvExpiry: s.cfg.MaxOutgoingCltvExpiry,
MaxChannelFeeAllocation: s.cfg.MaxChannelFeeAllocation, MaxChannelFeeAllocation: s.cfg.MaxChannelFeeAllocation,
CoopCloseTargetConfs: s.cfg.CoopCloseTargetConfs,
MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte( MaxAnchorsCommitFeeRate: chainfee.SatPerKVByte(
s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(), s.cfg.MaxCommitFeeRateAnchors * 1000).FeePerKWeight(),
Quit: s.quit, Quit: s.quit,