From 618855133d4ae4ece130aec3b35c5a65bea95b8f Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 15 Jul 2013 15:20:50 +1000 Subject: Refactor: CAddressBookData for mapAddressBook Straight refactor, so mapAddressBook stores a CAddressBookData (which just contains a std::string) instead of a std::string. Preparation for payment protocol work, which will add the notion of refund addresses to the address book. --- src/wallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index 8b9f3d34e..4f3516953 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -717,8 +717,8 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nReceived, { if (pwallet->mapAddressBook.count(r.first)) { - map::const_iterator mi = pwallet->mapAddressBook.find(r.first); - if (mi != pwallet->mapAddressBook.end() && (*mi).second == strAccount) + map::const_iterator mi = pwallet->mapAddressBook.find(r.first); + if (mi != pwallet->mapAddressBook.end() && (*mi).second.name == strAccount) nReceived += r.second; } else if (strAccount.empty()) @@ -1459,8 +1459,8 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet) bool CWallet::SetAddressBookName(const CTxDestination& address, const string& strName) { - std::map::iterator mi = mapAddressBook.find(address); - mapAddressBook[address] = strName; + std::map::iterator mi = mapAddressBook.find(address); + mapAddressBook[address].name = strName; NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED); if (!fFileBacked) return false; -- cgit v1.2.3 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/wallet.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index 4f3516953..c0f2d74ca 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) -- cgit v1.2.3 From a41d5fe01947f2f878c055670986a165af800f9a Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 22 Jul 2013 16:50:39 +1000 Subject: Payment Protocol: X509-validated payment requests Add support for a Payment Protocol to Bitcoin-Qt. Payment messages are protocol-buffer encoded and communicated over http(s), so this adds a dependency on the Google protocol buffer library, and requires Qt with OpenSSL support. --- src/wallet.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index c0f2d74ca..ddfd71efd 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -496,7 +496,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) if (GetKeyFromPool(newDefaultKey, false)) { SetDefaultKey(newDefaultKey); - SetAddressBookName(vchDefaultKey.GetID(), ""); + SetAddressBook(vchDefaultKey.GetID(), "", "receive"); } } } @@ -1457,26 +1457,28 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet) } -bool CWallet::SetAddressBookName(const CTxDestination& address, const string& strName) +bool CWallet::SetAddressBook(const CTxDestination& address, const string& strName, const string& strPurpose) { std::map::iterator mi = mapAddressBook.find(address); mapAddressBook[address].name = strName; NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED); if (!fFileBacked) return false; + if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose)) + return false; return CWalletDB(strWalletFile).WriteName(CBitcoinAddress(address).ToString(), strName); } -bool CWallet::DelAddressBookName(const CTxDestination& address) +bool CWallet::DelAddressBook(const CTxDestination& address) { mapAddressBook.erase(address); NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), CT_DELETED); if (!fFileBacked) return false; + CWalletDB(strWalletFile).ErasePurpose(CBitcoinAddress(address).ToString()); return CWalletDB(strWalletFile).EraseName(CBitcoinAddress(address).ToString()); } - void CWallet::PrintWallet(const CBlock& block) { { -- cgit v1.2.3