From 03fbd7904903928b0d1c8542a3d597aaf5bdd31b Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 5 Jul 2011 16:42:32 +0200 Subject: get rid of mapPubKeys Make CKeyStore's interface work on uint160's instead of pubkeys, so no separate global mapPubKeys is necessary anymore. --- src/ui.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/ui.cpp') diff --git a/src/ui.cpp b/src/ui.cpp index eae0a4f4c8..fba8ed8061 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -238,9 +238,10 @@ void SetDefaultReceivingAddress(const string& strAddress) uint160 hash160; if (!AddressToHash160(strAddress, hash160)) return; - if (!mapPubKeys.count(hash160)) + vector vchPubKey; + if (!pwalletMain->GetPubKey(hash160, vchPubKey)) return; - pwalletMain->SetDefaultKey(mapPubKeys[hash160]); + pwalletMain->SetDefaultKey(vchPubKey); pframeMain->m_textCtrlAddress->SetValue(strAddress); } } @@ -703,15 +704,15 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex) { if (pwalletMain->IsMine(txout)) { - vector vchPubKey; - if (ExtractPubKey(txout.scriptPubKey, pwalletMain, vchPubKey)) + uint160 hash160; + if (ExtractHash160(txout.scriptPubKey, pwalletMain, hash160)) { CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) { //strDescription += _("Received payment to "); //strDescription += _("Received with address "); strDescription += _("Received with: "); - string strAddress = PubKeyToAddress(vchPubKey); + string strAddress = Hash160ToAddress(hash160); map::iterator mi = pwalletMain->mapAddressBook.find(strAddress); if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) { @@ -786,7 +787,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex) { // Sent to Bitcoin Address uint160 hash160; - if (ExtractHash160(txout.scriptPubKey, hash160)) + if (ExtractHash160(txout.scriptPubKey, pwalletMain, hash160)) strAddress = Hash160ToAddress(hash160); } @@ -1502,10 +1503,10 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails { if (pwalletMain->IsMine(txout)) { - vector vchPubKey; - if (ExtractPubKey(txout.scriptPubKey, pwalletMain, vchPubKey)) + uint160 hash160; + if (ExtractHash160(txout.scriptPubKey, pwalletMain, hash160)) { - string strAddress = PubKeyToAddress(vchPubKey); + string strAddress = Hash160ToAddress(hash160); if (pwalletMain->mapAddressBook.count(strAddress)) { strHTML += string() + _("From: ") + _("unknown") + "
"; @@ -1589,7 +1590,7 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails { // Offline transaction uint160 hash160; - if (ExtractHash160(txout.scriptPubKey, hash160)) + if (ExtractHash160(txout.scriptPubKey, pwalletMain, hash160)) { string strAddress = Hash160ToAddress(hash160); strHTML += _("To: "); @@ -2630,7 +2631,7 @@ CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInit string strAddress = item.first; string strName = item.second; uint160 hash160; - bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160)); + bool fMine = (AddressToHash160(strAddress, hash160) && pwalletMain->HaveKey(hash160)); wxListCtrl* plistCtrl = fMine ? m_listCtrlReceiving : m_listCtrlSending; int nIndex = InsertLine(plistCtrl, strName, strAddress); if (strAddress == (fMine ? strDefaultReceiving : string(strInitSelected))) @@ -2741,7 +2742,7 @@ void CAddressBookDialog::OnButtonCopy(wxCommandEvent& event) bool CAddressBookDialog::CheckIfMine(const string& strAddress, const string& strTitle) { uint160 hash160; - bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160)); + bool fMine = (AddressToHash160(strAddress, hash160) && pwalletMain->HaveKey(hash160)); if (fMine) wxMessageBox(_("This is one of your own addresses for receiving payments and cannot be entered in the address book. "), strTitle); return fMine; -- cgit v1.2.3