Skip to content

Commit 050bb49

Browse files
committed
Add getpakinfo RPC call, without wallet state
1 parent 3cfe2d4 commit 050bb49

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/rpc/misc.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,54 @@ UniValue tweakfedpegscript(const JSONRPCRequest& request)
492492
return ret;
493493
}
494494

495+
UniValue FormatPAKList(CPAKList &paklist) {
496+
UniValue paklist_value(UniValue::VOBJ);
497+
std::vector<std::vector<unsigned char> > offline_keys;
498+
std::vector<std::vector<unsigned char> > online_keys;
499+
bool is_reject;
500+
paklist.ToBytes(offline_keys, online_keys, is_reject);
501+
502+
UniValue retOnline(UniValue::VARR);
503+
UniValue retOffline(UniValue::VARR);
504+
for (unsigned int i = 0; i < offline_keys.size(); i++) {
505+
retOffline.push_back(HexStr(offline_keys[i]));
506+
retOnline.push_back(HexStr(online_keys[i]));
507+
508+
}
509+
paklist_value.push_back(Pair("online", retOnline));
510+
paklist_value.push_back(Pair("offline", retOffline));
511+
paklist_value.push_back(Pair("reject", is_reject));
512+
return paklist_value;
513+
}
514+
515+
UniValue getpakinfo(const JSONRPCRequest& request)
516+
{
517+
if (request.fHelp || request.params.size() != 0)
518+
throw std::runtime_error(
519+
"getpakinfo\n"
520+
"\nReturns relevant pegout authorization key (PAK) information about this node, both from command line arguments and blockchain data.\n"
521+
"\nResult:\n"
522+
"{\n"
523+
"\"config_paklist\" (array) The PAK list loaded from beta.conf at startup\n"
524+
"\"block_paklist\" (array) The PAK list loaded from latest block commitment\n"
525+
"}\n"
526+
);
527+
528+
LOCK(cs_main);
529+
530+
531+
UniValue paklist_value(UniValue::VOBJ);
532+
if (g_paklist_config) {
533+
paklist_value = FormatPAKList(*g_paklist_config);
534+
}
535+
UniValue ret(UniValue::VOBJ);
536+
ret.pushKV("config_paklist", paklist_value);
537+
ret.pushKV("block_paklist", FormatPAKList(g_paklist_blockchain));
538+
539+
return ret;
540+
}
541+
542+
495543
// END ELEMENTS CALLS
496544
//
497545

@@ -517,6 +565,7 @@ static const CRPCCommand commands[] =
517565
{ "util", "verifymessage", &verifymessage, {"address","signature","message"} },
518566
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
519567
// ELEMENTS:
568+
{ "util", "getpakinfo", &getpakinfo, {}},
520569
{ "util", "tweakfedpegscript", &tweakfedpegscript, {"claim_script"} },
521570

522571
/* Not shown in help */

0 commit comments

Comments
 (0)