Add AccountID to json output for AccountState.

This commit is contained in:
Arthur Britto
2012-08-20 16:45:30 -07:00
parent 58644fc806
commit c16fe1e725
2 changed files with 16 additions and 7 deletions

View File

@@ -10,11 +10,12 @@
#include "Ledger.h"
#include "Serializer.h"
AccountState::AccountState(const NewcoinAddress& id) : mValid(false)
AccountState::AccountState(const NewcoinAddress& naAccountID) : mAccountID(naAccountID), mValid(false)
{
if (!id.isValid()) return;
if (!naAccountID.isValid()) return;
mLedgerEntry = boost::make_shared<SerializedLedgerEntry>(ltACCOUNT_ROOT);
mLedgerEntry->setIndex(Ledger::getAccountRootIndex(id));
mLedgerEntry->setIndex(Ledger::getAccountRootIndex(naAccountID));
mValid = true;
}
@@ -41,10 +42,17 @@ void AccountState::addJson(Json::Value& val)
{
val = mLedgerEntry->getJson(0);
if (!mValid) val["Invalid"] = true;
if (mValid)
{
val["AccountID"] = mAccountID.humanAccountID();
if (mLedgerEntry->getIFieldPresent(sfEmailHash))
val["UrlGravatar"] = createGravatarUrl(mLedgerEntry->getIFieldH128(sfEmailHash));
if (mLedgerEntry->getIFieldPresent(sfEmailHash))
val["UrlGravatar"] = createGravatarUrl(mLedgerEntry->getIFieldH128(sfEmailHash));
}
else
{
val["Invalid"] = true;
}
}
void AccountState::dump()

View File

@@ -21,13 +21,14 @@ public:
typedef boost::shared_ptr<AccountState> pointer;
private:
NewcoinAddress mAccountID;
NewcoinAddress mAuthorizedKey;
SerializedLedgerEntry::pointer mLedgerEntry;
bool mValid;
public:
AccountState(const NewcoinAddress& AccountID); // For new accounts
AccountState(const NewcoinAddress& naAccountID); // For new accounts
AccountState(const SerializedLedgerEntry::pointer& ledgerEntry); // For accounts in a ledger
bool bHaveAuthorizedKey()