From 9d2974ed5b4e32d7a3787e10642ee80910f8a5e7 Mon Sep 17 00:00:00 2001 From: Jay Graber Date: Wed, 27 Dec 2017 12:58:42 -0800 Subject: [PATCH 1/2] Add getdeprecationinfo rpc call to return current version and deprecation block height. --- src/rpcnet.cpp | 28 ++++++++++++++++++++++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 3 files changed, 30 insertions(+) diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index dc46c786e..03d96f8b2 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) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getdeprecationinfo\n" + "Returns an object containing current version and deprecation block height.\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 7a3880902..b531b2883 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 321568748..178befd38 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); From df46562f261592d8a5ddde14dea5d208269db260 Mon Sep 17 00:00:00 2001 From: Jay Graber Date: Wed, 17 Jan 2018 01:25:58 -0800 Subject: [PATCH 2/2] Make applicable only on mainnet --- src/rpcnet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 03d96f8b2..6f908516d 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -401,10 +401,11 @@ static UniValue GetNetworksInfo() UniValue getdeprecationinfo(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 0) + 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.\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" @@ -416,9 +417,8 @@ UniValue getdeprecationinfo(const UniValue& params, bool fHelp) + HelpExampleRpc("getdeprecationinfo", "") ); - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); + 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));