aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2024-01-11 16:27:32 -0500
committerPieter Wuille <pieter@wuille.net>2024-01-12 09:31:31 -0500
commit3ba815b42db74804e341ce15f648c2b297af55ca (patch)
tree83c572e2153fb5009717f53c3578a5b312c656c7
parent3ba8de1b704d590fa4e1975620bd21d830d11666 (diff)
downloadbitcoin-3ba815b42db74804e341ce15f648c2b297af55ca.tar.xz
Make v2transport default for addnode RPC when enabled
-rw-r--r--src/rpc/net.cpp7
-rwxr-xr-xtest/functional/test_framework/test_framework.py6
2 files changed, 7 insertions, 6 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 5fea8c22c9..e53f889897 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -313,7 +313,7 @@ static RPCHelpMan addnode()
{
{"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the peer to connect to"},
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
- {"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
+ {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
@@ -332,9 +332,10 @@ static RPCHelpMan addnode()
CConnman& connman = EnsureConnman(node);
const std::string node_arg{request.params[0].get_str()};
- bool use_v2transport = self.Arg<bool>(2);
+ bool node_v2transport = connman.GetLocalServices() & NODE_P2P_V2;
+ bool use_v2transport = self.MaybeArg<bool>(2).value_or(node_v2transport);
- if (use_v2transport && !(node.connman->GetLocalServices() & NODE_P2P_V2)) {
+ if (use_v2transport && !node_v2transport) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: v2transport requested but not enabled (see -v2transport)");
}
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 0ee332b75b..4baf12c3f9 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -602,10 +602,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if peer_advertises_v2 is None:
peer_advertises_v2 = from_connection.use_v2transport
- if peer_advertises_v2:
- from_connection.addnode(node=ip_port, command="onetry", v2transport=True)
+ if peer_advertises_v2 != from_connection.use_v2transport:
+ from_connection.addnode(node=ip_port, command="onetry", v2transport=peer_advertises_v2)
else:
- # skip the optional third argument (default false) for
+ # skip the optional third argument if it matches the default, for
# compatibility with older clients
from_connection.addnode(ip_port, "onetry")