diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index dc46c786e..6f908516d 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -13,6 +13,7 @@ #include "timedata.h" #include "util.h" #include "version.h" +#include "deprecation.h" #include @@ -398,6 +399,33 @@ static UniValue GetNetworksInfo() return networks; } +UniValue getdeprecationinfo(const UniValue& params, bool fHelp) +{ + const CChainParams& chainparams = Params(); + if (fHelp || params.size() != 0 || chainparams.NetworkIDString() != "main") + throw runtime_error( + "getdeprecationinfo\n" + "Returns an object containing current version and deprecation block height. Applicable only on mainnet.\n" + "\nResult:\n" + "{\n" + " \"version\": xxxxx, (numeric) the server version\n" + " \"subversion\": \"/MagicBean:x.y.z[-v]/\", (string) the server subversion string\n" + " \"deprecationheight\": xxxxx, (numeric) the block height at which this version will deprecate and shut down (unless -disabledeprecation is set)\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getdeprecationinfo", "") + + HelpExampleRpc("getdeprecationinfo", "") + ); + + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("version", CLIENT_VERSION)); + obj.push_back(Pair("subversion", + FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector()))); + obj.push_back(Pair("deprecationheight", DEPRECATION_HEIGHT)); + + return obj; +} + UniValue getnetworkinfo(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 0) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 4859a5ee3..f241bea86 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -265,6 +265,7 @@ static const CRPCCommand vRPCCommands[] = /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, + { "network", "getdeprecationinfo", &getdeprecationinfo, true }, { "network", "addnode", &addnode, true }, { "network", "disconnectnode", &disconnectnode, true }, { "network", "getaddednodeinfo", &getaddednodeinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 5359f46dd..d93efb4fc 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -238,6 +238,7 @@ extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); +extern UniValue getdeprecationinfo(const UniValue& params, bool fHelp); extern UniValue setmocktime(const UniValue& params, bool fHelp); extern UniValue resendwallettransactions(const UniValue& params, bool fHelp); extern UniValue zc_benchmark(const UniValue& params, bool fHelp);