add pubkey output to getinfo, and try setpubkey RPC

This commit is contained in:
blackjok3r
2018-10-24 12:49:12 +08:00
parent c4ee47ec36
commit 9920c80bde
4 changed files with 15 additions and 12 deletions

View File

@@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS
UniValue getinfo(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp)
{ {
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height;
extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[];
if (fHelp || params.size() != 0) if (fHelp || params.size() != 0)
throw runtime_error( throw runtime_error(
"getinfo\n" "getinfo\n"
@@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("pubkey", pubkeystr)); obj.push_back(Pair("pubkey", pubkeystr));
if ( KOMODO_LASTMINED != 0 ) if ( KOMODO_LASTMINED != 0 )
obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); obj.push_back(Pair("lastmined", KOMODO_LASTMINED));
} else if ( NOTARY_PUBKEY33[0] != 0 ) {
obj.push_back(Pair("pubkey", NOTARY_PUBKEY));
} }
} }
if ( ASSETCHAINS_CC != 0 ) if ( ASSETCHAINS_CC != 0 )

View File

@@ -264,7 +264,7 @@ static const CRPCCommand vRPCCommands[] =
{ "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
{ "control", "help", &help, true }, { "control", "help", &help, true },
{ "control", "stop", &stop, true }, { "control", "stop", &stop, true },
{ "control", "getpubkey", &getpubkey, true }, { "control", "setpubkey", &setpubkey, true },
/* P2P networking */ /* P2P networking */
{ "network", "getnetworkinfo", &getnetworkinfo, true }, { "network", "getnetworkinfo", &getnetworkinfo, true },

View File

@@ -322,7 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp);
extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp);
extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp);
extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp);
extern UniValue getpubkey(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp);
extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp);
extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp);

View File

@@ -4953,13 +4953,13 @@ UniValue channelsaddress(const UniValue& params, bool fHelp)
return(result); return(result);
} }
UniValue getpubkey(const UniValue& params, bool fHelp) UniValue setpubkey(const UniValue& params, bool fHelp)
{ {
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
if (fHelp || params.size() > 0) if ( fHelp || params.size() != 1 )
throw runtime_error( throw runtime_error(
"getpubkey\n" "setpubkey\n"
"\nReturns the -pubkey the daemon was started with.\n" "\Sets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n"
"\nResult:\n" "\nResult:\n"
"[\n" "[\n"
" {\n" " {\n"
@@ -4968,17 +4968,17 @@ UniValue getpubkey(const UniValue& params, bool fHelp)
"]\n" "]\n"
"\nExamples:\n" "\nExamples:\n"
"\nList pubkey.\n" "\nList pubkey.\n"
+ HelpExampleCli("getpubkey", "") + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e")
+ HelpExampleRpc("getpubkey", "") + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e")
); );
extern uint8_t NOTARY_PUBKEY33[]; extern uint8_t NOTARY_PUBKEY33[];
extern std::string NOTARY_PUBKEY; extern std::string NOTARY_PUBKEY;
if ( NOTARY_PUBKEY33[0] == 0 ) { if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 )) {
result.push_back(Pair("error","pubkey was not set!"; NOTARY_PUBKEY = params[0].get_str();
} else { decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
result.push_back(Pair("pubkey", NOTARY_PUBKEY);
} }
result.push_back(Pair("pubkey", NOTARY_PUBKEY);
return result; return result;
} }