From 78d552de22531259ebf499d834438c44fbf8b3fd Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 31 Jan 2024 15:05:50 +0800 Subject: [PATCH] config+rpcserver: hide deprecated option `unsafe-disconnect` Also fix a case where this deprecated flag is used. We will always bypass the active channels check when `DisconnectPeer` because `!r.cfg.UnsafeDisconnect` is always false. --- config.go | 3 +-- rpcserver.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index d510b7cf5..ec6220b9b 100644 --- a/config.go +++ b/config.go @@ -346,7 +346,7 @@ type Config struct { BlockingProfile int `long:"blockingprofile" description:"Used to enable a blocking profile to be served on the profiling port. This takes a value from 0 to 1, with 1 including every blocking event, and 0 including no events."` MutexProfile int `long:"mutexprofile" description:"Used to Enable a mutex profile to be served on the profiling port. This takes a value from 0 to 1, with 1 including every mutex event, and 0 including no events."` - UnsafeDisconnect bool `long:"unsafe-disconnect" description:"DEPRECATED: Allows the rpcserver to intentionally disconnect from peers with open channels. THIS FLAG WILL BE REMOVED IN 0.10.0"` + UnsafeDisconnect bool `long:"unsafe-disconnect" description:"DEPRECATED: Allows the rpcserver to intentionally disconnect from peers with open channels. THIS FLAG WILL BE REMOVED IN 0.10.0" hidden:"true"` UnsafeReplay bool `long:"unsafe-replay" description:"Causes a link to replay the adds on its commitment txn after starting up, this enables testing of the sphinx replay logic."` MaxPendingChannels int `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."` BackupFilePath string `long:"backupfilepath" description:"The target location of the channel backup file"` @@ -576,7 +576,6 @@ func DefaultConfig() Config { UserAgentVersion: neutrino.UserAgentVersion, }, BlockCacheSize: defaultBlockCacheSize, - UnsafeDisconnect: true, MaxPendingChannels: lncfg.DefaultMaxPendingChannels, NoSeedBackup: defaultNoSeedBackup, MinBackoff: defaultMinBackoff, diff --git a/rpcserver.go b/rpcserver.go index 25140c4d0..95bdd39bf 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1747,7 +1747,7 @@ func (r *rpcServer) DisconnectPeer(ctx context.Context, // In order to avoid erroneously disconnecting from a peer that we have // an active channel with, if we have any channels active with this // peer, then we'll disallow disconnecting from them. - if len(nodeChannels) > 0 && !r.cfg.UnsafeDisconnect { + if len(nodeChannels) > 0 { return nil, fmt.Errorf("cannot disconnect from peer(%x), "+ "all active channels with the peer need to be closed "+ "first", pubKeyBytes)