From 26bcde4d37ca1f16dad9bbb99a487ee9b67f0819 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 31 Dec 2011 18:10:30 -0800 Subject: [PATCH] Helper functions. --- Wallet.cpp | 17 +++++++++++++++++ Wallet.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/Wallet.cpp b/Wallet.cpp index 3c53679c62..a3f9f9d5dc 100644 --- a/Wallet.cpp +++ b/Wallet.cpp @@ -294,6 +294,23 @@ CKey::pointer LocalAccount::getPrivateKey() return la->getPrivKey(); } +void Wallet::getFamilies(std::vector& familyIDs) +{ + familyIDs.reserve(families.size()); + for(std::map::iterator fit=families.begin(); fit!=families.end(); ++fit) + familyIDs.push_back(fit->first); +} + +bool Wallet::getFamilyInfo(const uint160& family, std::string& name, std::string& comment) +{ + std::map::iterator fit=families.find(family); + if(fit==families.end()) return false; + assert(fit->second->getFamily()==family); + name=fit->second->getShortName(); + comment=fit->second->getComment(); + return true; +} + void Wallet::load() { std::string sql("SELECT * FROM LocalAcctFamilies"); diff --git a/Wallet.h b/Wallet.h index 5d87d240e7..81b81d4ebb 100644 --- a/Wallet.h +++ b/Wallet.h @@ -94,6 +94,7 @@ public: std::string getPubKeyHex() const; // The text name of the public key std::string getShortName() const { return mName; } + std::string getComment() const { return mComment; } static std::string getSQLFields(); std::string getSQL() const; @@ -154,6 +155,8 @@ public: void delFamily(const uint160& familyName); + void getFamilies(std::vector& familyIDs); + uint160 unlock(const uint256& passPhrase); bool lock(const uint160& familyName); @@ -163,6 +166,7 @@ public: LocalAccount::pointer getLocalAccount(const uint160& acctID); std::string getPubKeyHex(const uint160& famBase); std::string getShortName(const uint160& famBase); + bool getFamilyInfo(const uint160& family, std::string& name, std::string& comment); static bool unitTest(); };