@@ -921,6 +921,7 @@ static RPCHelpMan addpeeraddress()
921921 {
922922 {" address" , RPCArg::Type::STR, RPCArg::Optional::NO, " The IP address of the peer" },
923923 {" port" , RPCArg::Type::NUM, RPCArg::Optional::NO, " The port of the peer" },
924+ {" tried" , RPCArg::Type::BOOL, RPCArg::Default{false }, " If true, attempt to add the peer to the tried addresses table" },
924925 },
925926 RPCResult{
926927 RPCResult::Type::OBJ, " " , " " ,
@@ -929,8 +930,8 @@ static RPCHelpMan addpeeraddress()
929930 },
930931 },
931932 RPCExamples{
932- HelpExampleCli (" addpeeraddress" , " \" 1.2.3.4\" 8333" )
933- + HelpExampleRpc (" addpeeraddress" , " \" 1.2.3.4\" , 8333" )
933+ HelpExampleCli (" addpeeraddress" , " \" 1.2.3.4\" 8333 true " )
934+ + HelpExampleRpc (" addpeeraddress" , " \" 1.2.3.4\" , 8333, true " )
934935 },
935936 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
936937{
@@ -941,6 +942,7 @@ static RPCHelpMan addpeeraddress()
941942
942943 const std::string& addr_string{request.params [0 ].get_str ()};
943944 const uint16_t port{static_cast <uint16_t >(request.params [1 ].get_int ())};
945+ const bool tried{request.params [2 ].isTrue ()};
944946
945947 UniValue obj (UniValue::VOBJ);
946948 CNetAddr net_addr;
@@ -951,7 +953,13 @@ static RPCHelpMan addpeeraddress()
951953 address.nTime = GetAdjustedTime ();
952954 // The source address is set equal to the address. This is equivalent to the peer
953955 // announcing itself.
954- if (node.addrman ->Add ({address}, address)) success = true ;
956+ if (node.addrman ->Add ({address}, address)) {
957+ success = true ;
958+ if (tried) {
959+ // Attempt to move the address to the tried addresses table.
960+ node.addrman ->Good (address);
961+ }
962+ }
955963 }
956964
957965 obj.pushKV (" success" , success);
0 commit comments