From c5aa1b139a983613b1d5acc8f57804a9c66d4ff1 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 2 Sep 2011 18:02:22 +0200 Subject: update to work with new lock system, add protocol.* to build system --- src/qt/addresstablemodel.cpp | 22 +++++++++++++--------- src/qt/addresstablemodel.h | 3 ++- src/qt/clientmodel.cpp | 2 +- src/qt/editaddressdialog.cpp | 5 +++++ src/qt/transactiondesc.cpp | 4 ++-- src/qt/transactiontablemodel.cpp | 10 +++++----- src/qt/walletmodel.cpp | 8 ++++---- 7 files changed, 32 insertions(+), 22 deletions(-) (limited to 'src/qt') diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 6bda1e770c..8fd6d52b7e 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -39,8 +39,7 @@ struct AddressTablePriv { cachedAddressTable.clear(); - CRITICAL_BLOCK(wallet->cs_KeyStore) - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook) { @@ -170,7 +169,7 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu // Double-check that we're not overwriting a receiving address if(rec->type == AddressTableEntry::Sending) { - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { // Remove old entry wallet->DelAddressBookName(rec->address.toStdString()); @@ -255,7 +254,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con return QString(); } // Check for duplicate addresses - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { if(wallet->mapAddressBook.count(strAddress)) { @@ -274,15 +273,20 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con editStatus = WALLET_UNLOCK_FAILURE; return QString(); } - - strAddress = CBitcoinAddress(wallet->GetOrReuseKeyFromPool()).ToString(); + std::vector newKey; + if(!wallet->GetKeyFromPool(newKey, true)) + { + editStatus = KEY_GENERATION_FAILURE; + return QString(); + } + strAddress = CBitcoinAddress(newKey).ToString(); } else { return QString(); } // Add entry and update list - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) wallet->SetAddressBookName(strAddress, strLabel); updateList(); return QString::fromStdString(strAddress); @@ -298,7 +302,7 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex & paren // Also refuse to remove receiving addresses. return false; } - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { wallet->DelAddressBookName(rec->address.toStdString()); } @@ -315,7 +319,7 @@ void AddressTableModel::update() */ QString AddressTableModel::labelForAddress(const QString &address) const { - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { CBitcoinAddress address_parsed(address.toStdString()); std::map::iterator mi = wallet->mapAddressBook.find(address_parsed); diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h index bc505c48f0..f4a8dad845 100644 --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -29,7 +29,8 @@ public: OK, INVALID_ADDRESS, DUPLICATE_ADDRESS, - WALLET_UNLOCK_FAILURE + WALLET_UNLOCK_FAILURE, + KEY_GENERATION_FAILURE }; static const QString Send; /* Send addres */ diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 5cf02eac7d..d307473102 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -61,7 +61,7 @@ bool ClientModel::inInitialBlockDownload() const int ClientModel::getTotalBlocksEstimate() const { - return GetTotalBlocksEstimate(); + return GetMaxBlocksOfOtherNodes(); } OptionsModel *ClientModel::getOptionsModel() diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index 06e74db25a..b8e6fe4578 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -97,6 +97,11 @@ void EditAddressDialog::accept() tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); return; + case AddressTableModel::KEY_GENERATION_FAILURE: + QMessageBox::critical(this, windowTitle(), + tr("New key generation failed."), + QMessageBox::Ok, QMessageBox::Ok); + return; } return; diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 612b5d8974..6ca3ac8c4b 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -50,7 +50,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { QString strHTML; - CRITICAL_BLOCK(wallet->cs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { strHTML.reserve(4000); strHTML += ""; @@ -257,7 +257,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += "
Inputs:"; strHTML += "
    "; - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { BOOST_FOREACH(const CTxIn& txin, wtx.vin) { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 353cd79145..0e1733f156 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -69,7 +69,7 @@ struct TransactionTablePriv qDebug() << "refreshWallet"; #endif cachedWallet.clear(); - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { for(std::map::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it) { @@ -95,7 +95,7 @@ struct TransactionTablePriv QList updated_sorted = updated; qSort(updated_sorted); - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx) { @@ -171,7 +171,7 @@ struct TransactionTablePriv // simply re-use the cached status. if(rec->statusUpdateNeeded()) { - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { std::map::iterator mi = wallet->mapWallet.find(rec->hash); @@ -191,7 +191,7 @@ struct TransactionTablePriv QString describe(TransactionRecord *rec) { - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { std::map::iterator mi = wallet->mapWallet.find(rec->hash); if(mi != wallet->mapWallet.end()) @@ -229,7 +229,7 @@ void TransactionTableModel::update() QList updated; // Check if there are changes to wallet map - TRY_CRITICAL_BLOCK(wallet->cs_mapWallet) + TRY_CRITICAL_BLOCK(wallet->cs_wallet) { if(!wallet->vWalletUpdated.empty()) { diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index dfededca93..2f989661f0 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -38,7 +38,7 @@ qint64 WalletModel::getUnconfirmedBalance() const int WalletModel::getNumTransactions() const { int numTransactions = 0; - CRITICAL_BLOCK(wallet->cs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { numTransactions = wallet->mapWallet.size(); } @@ -117,7 +117,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QListcs_mapWallet) + CRITICAL_BLOCK(wallet->cs_wallet) { // Sendmany std::vector > vecSend; @@ -156,7 +156,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QListcs_mapAddressBook) + CRITICAL_BLOCK(wallet->cs_wallet) { if (!wallet->mapAddressBook.count(strAddress)) wallet->SetAddressBookName(strAddress, rcp.label.toStdString()); @@ -231,7 +231,7 @@ bool WalletModel::setWalletLocked(bool locked, const std::string &passPhrase) bool WalletModel::changePassphrase(const std::string &oldPass, const std::string &newPass) { bool retval; - CRITICAL_BLOCK(wallet->cs_vMasterKey) + CRITICAL_BLOCK(wallet->cs_wallet) { wallet->Lock(); // Make sure wallet is locked before attempting pass change retval = wallet->ChangeWalletPassphrase(oldPass, newPass); -- cgit v1.2.3