config: add new --v2transport option to gate BIP 324

This commit is contained in:
Olaoluwa Osuntokun 2025-05-26 13:43:22 -07:00
parent ef0e43ba06
commit 5ab25f3f2b
3 changed files with 11 additions and 1 deletions

View file

@ -177,6 +177,7 @@ type config struct {
TrickleInterval time.Duration `long:"trickleinterval" description:"Minimum time between attempts to send new inventory to a connected peer"`
UtxoCacheMaxSizeMiB uint `long:"utxocachemaxsize" description:"The maximum size in MiB of the UTXO cache"`
TxIndex bool `long:"txindex" description:"Maintain a full hash-based transaction index which makes all transactions available via the getrawtransaction RPC"`
V2Transport bool `long:"v2transport" description:"Enable P2P v2 encrypted transport protocol (BIP324) (default: false)"`
UserAgentComments []string `long:"uacomment" description:"Comment to add to the user agent -- See BIP 14 for more information."`
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
@ -442,6 +443,7 @@ func loadConfig() (*config, []string, error) {
Generate: defaultGenerate,
TxIndex: defaultTxIndex,
AddrIndex: defaultAddrIndex,
V2Transport: false,
}
// Service options which are only added on Windows.

View file

@ -176,6 +176,11 @@
; Disable committed peer filtering (CF).
; nocfilters=1
; Enable or disable the P2P v2 encrypted transport protocol (BIP324).
; If disabled (which is the default), btcd will only attempt to use the
; v1 P2P protocol. (default: 0)
; v2transport=0
; ------------------------------------------------------------------------------
; RPC server options - The following options control the built-in RPC server
; which is used to control and query information from a running btcd process.

View file

@ -2182,7 +2182,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config {
ProtocolVersion: peer.MaxProtocolVersion,
TrickleInterval: cfg.TrickleInterval,
DisableStallHandler: cfg.DisableStallHandler,
UsingV2Conn: true,
UsingV2Conn: cfg.V2Transport,
}
}
@ -2782,6 +2782,9 @@ func newServer(listenAddrs, agentBlacklist, agentWhitelist []string,
if cfg.Prune != 0 {
services &^= wire.SFNodeNetwork
}
if !cfg.V2Transport {
services &^= wire.SFNodeP2PV2
}
amgr := addrmgr.New(cfg.DataDir, btcdLookup)