diff --git a/Ledger.cpp b/Ledger.cpp index 62389d414c..d02e3ec64f 100644 --- a/Ledger.cpp +++ b/Ledger.cpp @@ -271,7 +271,9 @@ Ledger::pointer Ledger::closeLedger(uint64 timeStamp) void LocalAccount::syncLedger(const uint160& acctID) { - setLedgerBalance(theApp->getMasterLedger().getBalance(acctID)); + AccountState::pointer as=theApp->getMasterLedger().getAccountState(acctID); + if(!as) setLedgerBalance(0); + else syncLedger(as->getBalance(), as->getSeq()); } bool Ledger::unitTest() diff --git a/LocalAccount.h b/LocalAccount.h index 16bb8c75af..81fed6d6ab 100644 --- a/LocalAccount.h +++ b/LocalAccount.h @@ -44,7 +44,12 @@ public: int64 getEffectiveBalance() const { return static_cast(mLgrBalance)+mTxnDelta; } void credit(uint64 amount) { mTxnDelta+=amount; } void debit(uint64 amount) { mTxnDelta-=amount; } - void setLedgerBalance(uint64_t lb) { mLgrBalance=lb; } + void setLedgerBalance(uint64_t lb) { mLgrBalance=lb; if(mTxnSeq==0) mTxnSeq=1; } + void syncLedger(uint64_t lb, uint32 sq) + { + mLgrBalance=lb; + if(mTxnSeqgetEffectiveBalance(); } +void LocalAccount::syncLedger(uint64_t lb, uint32_t ls) +{ + LocalAccountEntry::pointer la(mFamily->get(mSeq)); + if(!la) return ; + la->syncLedger(lb, ls); +} + void LocalAccount::setLedgerBalance(uint64_t lb) { LocalAccountEntry::pointer la(mFamily->get(mSeq)); @@ -650,6 +657,14 @@ LocalAccountFamily::pointer Wallet::doPublic(const std::string& pubKey, bool do_ { // Generate root key EC_KEY *pkey=CKey::GenerateRootPubKey(pubKey); + if(!pkey) + { +#ifdef DEBUG + std::cerr << "Unable to generate root public key" << std::endl; + assert(false); +#endif + return LocalAccountFamily::pointer(); + } // Extract family name std::vector rootPubKey(33, 0);