MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / listaddr

Function listaddr

src/rpc/rpctx.cpp:495–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495Value listaddr(const Array& params, bool fHelp) {
496 if (fHelp || params.size() != 0) {
497 throw runtime_error(
498 "listaddr\n"
499 "\nreturn Array containing address, balance, haveminerkey, regid information.\n"
500 "\nArguments:\n"
501 "\nResult:\n"
502 "\nExamples:\n" +
503 HelpExampleCli("listaddr", "") + "\nAs json rpc call\n" + HelpExampleRpc("listaddr", ""));
504 }
505
506 Array retArray;
507 assert(pWalletMain != nullptr);
508 {
509 set<CKeyID> setKeyId;
510 pWalletMain->GetKeys(setKeyId);
511 if (setKeyId.size() == 0) {
512 return retArray;
513 }
514
515 for (const auto &keyid : setKeyId) {
516 CUserID userId(keyid);
517 CAccount account;
518 pCdMan->pAccountCache->GetAccount(userId, account);
519 CKeyCombi keyCombi;
520 pWalletMain->GetKeyCombi(keyid, keyCombi);
521
522 Object obj;
523 obj.push_back(Pair("addr", keyid.ToAddress()));
524 obj.push_back(Pair("regid", account.regid.ToString()));
525 obj.push_back(Pair("regid_mature", account.regid.IsMature(chainActive.Height())));
526 obj.push_back(Pair("received_votes",account.received_votes));
527
528 Object tokenMapObj;
529 for (auto tokenPair : account.tokens) {
530 Object tokenObj;
531 const CAccountToken& token = tokenPair.second;
532
533 tokenObj.push_back(Pair("free_amount", token.free_amount));
534 tokenObj.push_back(Pair("staked_amount", token.staked_amount));
535 tokenObj.push_back(Pair("frozen_amount", token.frozen_amount));
536 tokenObj.push_back(Pair("voted_amount", token.voted_amount));
537 tokenObj.push_back(Pair("pledged_amount", token.pledged_amount));
538
539 tokenMapObj.push_back(Pair(tokenPair.first, tokenObj));
540 }
541
542 obj.push_back(Pair("tokens", tokenMapObj));
543 obj.push_back(Pair("hasminerkey", keyCombi.HaveMinerKey()));
544
545 retArray.push_back(obj);
546 }
547 }
548
549 return retArray;
550}
551
552Value listtx(const Array& params, bool fHelp) {

Callers

nothing calls this directly

Calls 13

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
PairClass · 0.85
push_backMethod · 0.80
ToAddressMethod · 0.80
IsMatureMethod · 0.80
HeightMethod · 0.80
HaveMinerKeyMethod · 0.80
sizeMethod · 0.45
GetKeysMethod · 0.45
GetAccountMethod · 0.45
GetKeyCombiMethod · 0.45

Tested by

no test coverage detected