diff --git a/src/net.cpp b/src/net.cpp index 0f49b8ad5a..269a4f0e88 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -429,7 +429,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo std::vector resolved; if (Lookup(pszDest, resolved, default_port, fNameLookup && !HaveNameProxy(), 256) && !resolved.empty()) { const CService rnd{resolved[GetRand(resolved.size())]}; - addrConnect = CAddress{MaybeFlipIPv6toCJDNS(rnd), NODE_NONE}; + addrConnect = CAddress{MaybeFlipIPv6toCJDNS(rnd), addrConnect.nServices}; if (!addrConnect.IsValid()) { LogPrint(BCLog::NET, "Resolver returned invalid address %s for %s\n", addrConnect.ToString(), pszDest); return nullptr; @@ -2977,7 +2977,8 @@ ServiceFlags CConnman::GetLocalServices() const unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; } CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion) - : m_connected{GetTime()}, + : nServices(addrIn.nServices), + m_connected{GetTime()}, addr(addrIn), addrBind(addrBindIn), m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn}, diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index a171972da3..2520baac14 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -201,6 +201,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "addpeeraddress", 1, "port"}, { "addpeeraddress", 2, "tried"}, { "stop", 0, "wait" }, + { "addnode", 2, "services" }, }; // clang-format on diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 557b1296a6..0ef6a44094 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -276,11 +276,12 @@ static RPCHelpMan addnode() { {"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The node (see getpeerinfo for nodes)"}, {"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"}, + {"services", RPCArg::Type::NUM, RPCArg::Default{0}, "Advertised services for the peer"}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ - HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") - + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"") + HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\" 1033") + + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\" 1033") }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { @@ -300,6 +301,9 @@ static RPCHelpMan addnode() if (strCommand == "onetry") { CAddress addr; + if (!request.params[2].isNull()) { + addr.nServices = ServiceFlags{static_cast(request.params[2].get_int64())}; + } connman.OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), ConnectionType::MANUAL); return NullUniValue; }