From dfdddfd2ff8a1903666f652298944c90c96ecf0f Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:52:44 +0000 Subject: [PATCH] rpc: enable `v2transport` for `masternode connect` when capable --- src/rpc/masternode.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index b18f7ef06d..eb2d3a40b4 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -38,7 +38,7 @@ static RPCHelpMan masternode_connect() "Connect to given masternode\n", { {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the masternode to connect"}, - {"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol"}, + {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol"}, }, RPCResults{}, RPCExamples{""}, @@ -51,12 +51,13 @@ static RPCHelpMan masternode_connect() throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Incorrect masternode address %s", strAddress)); } - bool use_v2transport = !request.params[1].isNull() && ParseBoolV(request.params[1], "v2transport"); - const NodeContext& node = EnsureAnyNodeContext(request.context); CConnman& connman = EnsureConnman(node); - if (use_v2transport && !(connman.GetLocalServices() & NODE_P2P_V2)) { + bool node_v2transport = connman.GetLocalServices() & NODE_P2P_V2; + bool use_v2transport = request.params[1].isNull() ? node_v2transport : ParseBoolV(request.params[1], "v2transport"); + + if (use_v2transport && !node_v2transport) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: Adding v2transport connections requires -v2transport init flag to be set."); }