From c16fe1e725db2a0793815a5f35b15366fa11bd76 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Mon, 20 Aug 2012 16:45:30 -0700 Subject: [PATCH] Add AccountID to json output for AccountState. --- src/AccountState.cpp | 20 ++++++++++++++------ src/AccountState.h | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/AccountState.cpp b/src/AccountState.cpp index e9804926c2..b9cea5936b 100644 --- a/src/AccountState.cpp +++ b/src/AccountState.cpp @@ -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(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() diff --git a/src/AccountState.h b/src/AccountState.h index 9069f375b0..bd7503cb11 100644 --- a/src/AccountState.h +++ b/src/AccountState.h @@ -21,13 +21,14 @@ public: typedef boost::shared_ptr 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()