From c89a303493feda0b6ea0a00c031be937651ca204 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 9 Aug 2015 23:17:46 +0200 Subject: [PATCH] Brain wallet annotation in AZ. --- alethzero/MainWin.cpp | 2 +- libethcore/KeyManager.cpp | 1 - libethcore/KeyManager.h | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index ed2bfa1ad..1f9f4482c 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1179,7 +1179,7 @@ void Main::refreshBalances() for (auto const& address: m_keyManager.accounts()) { u256 b = ethereum()->balanceAt(address); - QListWidgetItem* li = new QListWidgetItem(QString("%4 %2: %1 [%3]").arg(formatBalance(b).c_str()).arg(QString::fromStdString(render(address))).arg((unsigned)ethereum()->countAt(address)).arg(QString::fromStdString(m_keyManager.accountName(address))), ui->ourAccounts); + QListWidgetItem* li = new QListWidgetItem(QString("<%5> %4 %2: %1 [%3]").arg(formatBalance(b).c_str()).arg(QString::fromStdString(render(address))).arg((unsigned)ethereum()->countAt(address)).arg(QString::fromStdString(m_keyManager.accountName(address))).arg(m_keyManager.haveKey(address) ? "KEY" : "BRAIN"), ui->ourAccounts); li->setData(Qt::UserRole, QByteArray((char const*)address.data(), Address::size)); li->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); li->setCheckState(m_beneficiary == address ? Qt::Checked : Qt::Unchecked); diff --git a/libethcore/KeyManager.cpp b/libethcore/KeyManager.cpp index ffd5cfaa5..ba6535085 100644 --- a/libethcore/KeyManager.cpp +++ b/libethcore/KeyManager.cpp @@ -112,7 +112,6 @@ bool KeyManager::load(string const& _pass) // TODO: brain wallet. m_keyInfo[addr] = KeyInfo(h256(i[2]), string(i[3]), i.itemCount() > 4 ? string(i[4]) : ""); } - // cdebug << toString(addr) << toString(uuid) << toString((h256)i[2]) << (string)i[3]; } diff --git a/libethcore/KeyManager.h b/libethcore/KeyManager.h index 2d9ea9394..671355df9 100644 --- a/libethcore/KeyManager.h +++ b/libethcore/KeyManager.h @@ -97,6 +97,9 @@ public: /// @returns the password hint for the account for the given address; std::string const& passwordHint(Address const& _address) const; + /// @returns true if the given address has a key (UUID) associated with it. Equivalent to !!uuid(_a) + /// If the address has no key, it could be a brain wallet. + bool haveKey(Address const& _a) const { return m_addrLookup.count(_a); } /// @returns the uuid of the key for the address @a _a or the empty hash on error. h128 uuid(Address const& _a) const; /// @returns the address corresponding to the key with uuid @a _uuid or the zero address on error.