diff options
-rwxr-xr-x | contrib/misc/linearize.py | 2 | ||||
-rw-r--r-- | src/qt/addresstablemodel.cpp | 40 | ||||
-rw-r--r-- | src/qt/addresstablemodel.h | 2 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 17 | ||||
-rw-r--r-- | src/qt/bitcoinaddressvalidator.h | 4 | ||||
-rw-r--r-- | src/qt/transactiontablemodel.cpp | 10 | ||||
-rw-r--r-- | src/qt/walletmodel.cpp | 17 | ||||
-rw-r--r-- | src/qt/walletmodel.h | 2 | ||||
-rw-r--r-- | src/wallet.cpp | 8 | ||||
-rw-r--r-- | src/wallet.h | 8 |
10 files changed, 65 insertions, 45 deletions
diff --git a/contrib/misc/linearize.py b/contrib/misc/linearize.py index b4f02b7954..2d8509f83c 100755 --- a/contrib/misc/linearize.py +++ b/contrib/misc/linearize.py @@ -89,7 +89,7 @@ def get_blocks(settings): if __name__ == '__main__': if len(sys.argv) != 2: - print "Usage: mkbootstrap.py CONFIG-FILE" + print "Usage: linearize.py CONFIG-FILE" sys.exit(1) f = open(sys.argv[1]) diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index ef8a001f31..be31b03749 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -15,7 +15,8 @@ struct AddressTableEntry { enum Type { Sending, - Receiving + Receiving, + Hidden /* QSortFilterProxyModel will filter these out */ }; Type type; @@ -43,6 +44,20 @@ struct AddressTableEntryLessThan } }; +/* Determine address type from address purpose */ +static AddressTableEntry::Type translateTransactionType(const QString &strPurpose, bool isMine) +{ + AddressTableEntry::Type addressType = AddressTableEntry::Hidden; + // "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all. + if (strPurpose == "send") + addressType = AddressTableEntry::Sending; + else if (strPurpose == "receive") + addressType = AddressTableEntry::Receiving; + else if (strPurpose == "unknown" || strPurpose == "") // if purpose not set, guess + addressType = (isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending); + return addressType; +} + // Private implementation class AddressTablePriv { @@ -62,17 +77,9 @@ public: BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; - - AddressTableEntry::Type addressType; - const std::string& strPurpose = item.second.purpose; - if (strPurpose == "send") addressType = AddressTableEntry::Sending; - else if (strPurpose == "receive") addressType = AddressTableEntry::Receiving; - else if (strPurpose == "unknown") { - bool fMine = IsMine(*wallet, address.Get()); - addressType = (fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending); - } - else continue; // "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all. - + bool fMine = IsMine(*wallet, address.Get()); + AddressTableEntry::Type addressType = translateTransactionType( + QString::fromStdString(item.second.purpose), fMine); const std::string& strName = item.second.name; cachedAddressTable.append(AddressTableEntry(addressType, QString::fromStdString(strName), @@ -85,7 +92,7 @@ public: qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); } - void updateEntry(const QString &address, const QString &label, bool isMine, int status) + void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status) { // Find address / label in model QList<AddressTableEntry>::iterator lower = qLowerBound( @@ -95,7 +102,7 @@ public: int lowerIndex = (lower - cachedAddressTable.begin()); int upperIndex = (upper - cachedAddressTable.begin()); bool inModel = (lower != upper); - AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending; + AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine); switch(status) { @@ -324,10 +331,11 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex &par } } -void AddressTableModel::updateEntry(const QString &address, const QString &label, bool isMine, int status) +void AddressTableModel::updateEntry(const QString &address, + const QString &label, bool isMine, const QString &purpose, int status) { // Update address book model from Bitcoin core - priv->updateEntry(address, label, isMine, status); + priv->updateEntry(address, label, isMine, purpose, status); } QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address) diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h index 48baff5e54..6f532087fe 100644 --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -85,7 +85,7 @@ signals: public slots: /* Update address list from core. */ - void updateEntry(const QString &address, const QString &label, bool isMine, int status); + void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status); friend class AddressTablePriv; }; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index f2386f3cff..a4d589e167 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -155,12 +155,12 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans #if QT_VERSION < 0x050000 void DebugMessageHandler(QtMsgType type, const char * msg) { - OutputDebugStringF("%s\n", msg); + OutputDebugStringF("Bitcoin-Qt: %s\n", msg); } #else void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg) { - OutputDebugStringF("%s\n", qPrintable(msg)); + OutputDebugStringF("Bitcoin-Qt: %s\n", qPrintable(msg)); } #endif @@ -236,6 +236,12 @@ int main(int argc, char *argv[]) // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); + // Install qDebug() message handler to route to debug.log +#if QT_VERSION < 0x050000 + qInstallMsgHandler(DebugMessageHandler); +#else + qInstallMessageHandler(DebugMessageHandler); +#endif // ... now GUI settings: OptionsModel optionsModel; @@ -255,13 +261,6 @@ int main(int argc, char *argv[]) return 1; } - // Install qDebug() message handler to route to debug.log: -#if QT_VERSION < 0x050000 - qInstallMsgHandler(DebugMessageHandler); -#else - qInstallMessageHandler(DebugMessageHandler); -#endif - SplashScreen splash(QPixmap(), 0); if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false)) { diff --git a/src/qt/bitcoinaddressvalidator.h b/src/qt/bitcoinaddressvalidator.h index 2b6a59367d..b7f4dfee96 100644 --- a/src/qt/bitcoinaddressvalidator.h +++ b/src/qt/bitcoinaddressvalidator.h @@ -3,8 +3,8 @@ #include <QValidator> -/** Base48 entry widget validator. - Corrects near-miss characters and refuses characters that are no part of base48. +/** Base58 entry widget validator. + Corrects near-miss characters and refuses characters that are not part of base58. */ class BitcoinAddressValidator : public QValidator { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 625e657295..9c040d5b63 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -20,11 +20,11 @@ // Amount column is right-aligned it contains numbers static int column_alignments[] = { - Qt::AlignLeft|Qt::AlignVCenter, - Qt::AlignLeft|Qt::AlignVCenter, - Qt::AlignLeft|Qt::AlignVCenter, - Qt::AlignLeft|Qt::AlignVCenter, - Qt::AlignRight|Qt::AlignVCenter + Qt::AlignLeft|Qt::AlignVCenter, /* status */ + Qt::AlignLeft|Qt::AlignVCenter, /* date */ + Qt::AlignLeft|Qt::AlignVCenter, /* type */ + Qt::AlignLeft|Qt::AlignVCenter, /* address */ + Qt::AlignRight|Qt::AlignVCenter /* amount */ }; // Comparison operator for sort/binary search of model tx list diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index cdc7ae3874..2d3a6975e4 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -111,10 +111,11 @@ void WalletModel::updateTransaction(const QString &hash, int status) } } -void WalletModel::updateAddressBook(const QString &address, const QString &label, bool isMine, int status) +void WalletModel::updateAddressBook(const QString &address, const QString &label, + bool isMine, const QString &purpose, int status) { if(addressTableModel) - addressTableModel->updateEntry(address, label, isMine, status); + addressTableModel->updateEntry(address, label, isMine, purpose, status); } bool WalletModel::validateAddress(const QString &address) @@ -362,13 +363,17 @@ static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStor QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection); } -static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, ChangeType status) +static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, + const CTxDestination &address, const std::string &label, bool isMine, + const std::string &purpose, ChangeType status) { - OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, status); + OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i purpose=%s status=%i\n", + CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, purpose.c_str(), status); QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())), Q_ARG(QString, QString::fromStdString(label)), Q_ARG(bool, isMine), + Q_ARG(QString, QString::fromStdString(purpose)), Q_ARG(int, status)); } @@ -384,7 +389,7 @@ void WalletModel::subscribeToCoreSignals() { // Connect signals to wallet wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); - wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5)); + wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); } @@ -392,7 +397,7 @@ void WalletModel::unsubscribeFromCoreSignals() { // Disconnect signals from wallet wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); - wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5)); + wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index f8eee45249..6abcdaf8cb 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -169,7 +169,7 @@ public slots: /* New transaction, or transaction changed status */ void updateTransaction(const QString &hash, int status); /* New, updated or removed address book entry */ - void updateAddressBook(const QString &address, const QString &label, bool isMine, int status); + void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status); /* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */ void pollBalanceChanged(); }; diff --git a/src/wallet.cpp b/src/wallet.cpp index 7a3855c025..54ede12a50 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1461,7 +1461,11 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam { std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address); mapAddressBook[address].name = strName; - NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED); + if (!strPurpose.empty()) /* update purpose only if requested */ + mapAddressBook[address].purpose = strPurpose; + NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), + mapAddressBook[address].purpose, + (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED); if (!fFileBacked) return false; if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose)) @@ -1472,7 +1476,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam bool CWallet::DelAddressBook(const CTxDestination& address) { mapAddressBook.erase(address); - NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), CT_DELETED); + NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), "", CT_DELETED); if (!fFileBacked) return false; CWalletDB(strWalletFile).ErasePurpose(CBitcoinAddress(address).ToString()); diff --git a/src/wallet.h b/src/wallet.h index d61548433e..b529d5f28b 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -335,12 +335,16 @@ public: /** Address book entry changed. * @note called with lock cs_wallet held. */ - boost::signals2::signal<void (CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, ChangeType status)> NotifyAddressBookChanged; + boost::signals2::signal<void (CWallet *wallet, const CTxDestination + &address, const std::string &label, bool isMine, + const std::string &purpose, + ChangeType status)> NotifyAddressBookChanged; /** Wallet transaction added, removed or updated. * @note called with lock cs_wallet held. */ - boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged; + boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx, + ChangeType status)> NotifyTransactionChanged; }; /** A key allocated from the key pool. */ |