Finish moving Json code.

This commit is contained in:
JoelKatz
2012-01-07 15:53:31 -08:00
parent 7935889f00
commit c65b9ecf83
3 changed files with 16 additions and 17 deletions

View File

@@ -205,13 +205,7 @@ Json::Value RPCServer::doAccountInfo(Json::Value &params)
if(!account)
return JSONRPCError(500, "Account not found");
Json::Value ret(Json::objectValue);
ret["Family"]=account->getFamilyName();
ret["ShortName"]=account->getShortName();
ret["FullName"]=account->getFullName();
ret["AccountID"]=NewcoinAddress(account->getAddress()).GetString();
ret["Issued"]=Json::Value(account->isIssued());
return ret;
return account->getJson();
}
Json::Value RPCServer::doNewAccount(Json::Value &params)
@@ -226,14 +220,7 @@ Json::Value RPCServer::doNewAccount(Json::Value &params)
LocalAccount::pointer account(theApp->getWallet().getNewLocalAccount(family));
if(!account)
return JSONRPCError(500, "Family not found");
Json::Value ret(Json::objectValue);
ret["Family"]=account->getFamilyName();
ret["ShortName"]=account->getShortName();
ret["FullName"]=account->getFullName();
ret["AccountID"]=NewcoinAddress(account->getAddress()).GetString();
ret["Issued"]=Json::Value(account->isIssued());
return ret;
return account->getJson();
}
Json::Value RPCServer::doLock(Json::Value &params)

View File

@@ -366,6 +366,18 @@ std::string LocalAccount::getFamilyName() const
return mFamily->getShortName();
}
Json::Value LocalAccount::getJson() const
{
Json::Value ret(Json::objectValue);
ret["Family"]=getFamilyName();
ret["AccountID"]=NewcoinAddress(getAddress()).GetString();
ret["ShortName"]=getShortName();
ret["FullName"]=getFullName();
ret["Issued"]=Json::Value(isIssued());
ret["IsLocked"]=mFamily->isLocked();
return ret;
}
bool LocalAccount::isIssued() const
{
return mSeq < mFamily->getSeq();

View File

@@ -138,7 +138,7 @@ public:
CKey::pointer getPublicKey();
CKey::pointer getPrivateKey();
Json::Value getJson();
Json::Value getJson() const;
};
class Wallet