From c65b9ecf83cb6bd508bb3f59001c470999430207 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 7 Jan 2012 15:53:31 -0800 Subject: [PATCH] Finish moving Json code. --- RPCServer.cpp | 19 +++---------------- Wallet.cpp | 12 ++++++++++++ Wallet.h | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/RPCServer.cpp b/RPCServer.cpp index 465aaa716..dcdb84d9c 100644 --- a/RPCServer.cpp +++ b/RPCServer.cpp @@ -204,14 +204,8 @@ Json::Value RPCServer::doAccountInfo(Json::Value ¶ms) LocalAccount::pointer account=theApp->getWallet().parseAccount(acct); 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 ¶ms) @@ -226,14 +220,7 @@ Json::Value RPCServer::doNewAccount(Json::Value ¶ms) 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 ¶ms) diff --git a/Wallet.cpp b/Wallet.cpp index 7b0c80ba5..5f4a47859 100644 --- a/Wallet.cpp +++ b/Wallet.cpp @@ -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(); diff --git a/Wallet.h b/Wallet.h index 93e77a62d..cf719398b 100644 --- a/Wallet.h +++ b/Wallet.h @@ -138,7 +138,7 @@ public: CKey::pointer getPublicKey(); CKey::pointer getPrivateKey(); - Json::Value getJson(); + Json::Value getJson() const; }; class Wallet