Add AccountState::addJson. Make RPC call "accountinfo <account>" work

on non-local accounts and local account by account identifier.
This commit is contained in:
JoelKatz
2012-01-23 16:58:17 -08:00
parent f4c6865751
commit 7215f5b220
4 changed files with 61 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
#include <boost/lexical_cast.hpp>
#include "AccountState.h"
#include "Serializer.h"
@@ -22,3 +25,30 @@ std::vector<unsigned char> AccountState::getRaw() const
s.add32(mAccountSeq);
return s.getData();
}
static bool isHex(char j)
{
if((j>='0') && (j<='9')) return true;
if((j>='A') && (j<='F')) return true;
if((j>='a') && (j<='f')) return true;
return false;
}
bool AccountState::isHexAccountID(const std::string& acct)
{
if(acct.size()!=40) return false;
for(int i=1; i<40; i++)
if(!isHex(acct[i])) return false;
return true;
}
void AccountState::addJson(Json::Value& val)
{
Json::Value as(Json::objectValue);
as["Account"]=mAccountID.GetHex();
as["Balance"]=boost::lexical_cast<std::string>(mBalance);
as["SendSequence"]=mAccountSeq;
if(!mValid) as["Invalid"]=true;
NewcoinAddress nad(mAccountID);
val[nad.GetString()]=as;
}