From 3624356e82015c980fa7b7e60dfbe128665b1952 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 16 Jul 2013 09:01:09 +1000 Subject: Refactor: Move GetAccountAddresses to CWallet --- src/rpcwallet.cpp | 14 +------------- src/wallet.cpp | 13 +++++++++++++ src/wallet.h | 7 ++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index b233b654b5..78f561a0a9 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -421,17 +421,6 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) } -void GetAccountAddresses(string strAccount, set& setAddress) -{ - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, pwalletMain->mapAddressBook) - { - const CTxDestination& address = item.first; - const string& strName = item.second.name; - if (strName == strAccount) - setAddress.insert(address); - } -} - Value getreceivedbyaccount(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -446,8 +435,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp) // Get the set of pub keys assigned to account string strAccount = AccountFromValue(params[0]); - set setAddress; - GetAccountAddresses(strAccount, setAddress); + set setAddress = pwalletMain->GetAccountAddresses(strAccount); // Tally int64 nAmount = 0; diff --git a/src/wallet.cpp b/src/wallet.cpp index 4f3516953c..c0f2d74ca7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1812,6 +1812,19 @@ set< set > CWallet::GetAddressGroupings() return ret; } +set CWallet::GetAccountAddresses(string strAccount) const +{ + set result; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook) + { + const CTxDestination& address = item.first; + const string& strName = item.second.name; + if (strName == strAccount) + result.insert(address); + } + return result; +} + bool CReserveKey::GetReservedKey(CPubKey& pubkey) { if (nIndex == -1) diff --git a/src/wallet.h b/src/wallet.h index a3bcc26c5e..8b9ccaf5cb 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -73,11 +73,6 @@ public: CAddressBookData() { } - - IMPLEMENT_SERIALIZE - ( - READWRITE(name); - ) }; /** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, @@ -230,6 +225,8 @@ public: std::set< std::set > GetAddressGroupings(); std::map GetAddressBalances(); + std::set GetAccountAddresses(std::string strAccount) const; + bool IsMine(const CTxIn& txin) const; int64 GetDebit(const CTxIn& txin) const; bool IsMine(const CTxOut& txout) const -- cgit v1.2.3