From 5ab25f3f2bd418fba09325c0f496f56aca03e9a3 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 26 May 2025 13:43:22 -0700 Subject: [PATCH] config: add new --v2transport option to gate BIP 324 --- config.go | 2 ++ sample-btcd.conf | 5 +++++ server.go | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 04f926c2..cb7ce6b2 100644 --- a/config.go +++ b/config.go @@ -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. diff --git a/sample-btcd.conf b/sample-btcd.conf index 0fb688fb..103f75b8 100644 --- a/sample-btcd.conf +++ b/sample-btcd.conf @@ -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. diff --git a/server.go b/server.go index 59614f00..b45db2bb 100644 --- a/server.go +++ b/server.go @@ -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)