diff --git a/alethzero/BrainWallet.cpp b/alethzero/BrainWallet.cpp
new file mode 100644
index 000000000..c6c710811
--- /dev/null
+++ b/alethzero/BrainWallet.cpp
@@ -0,0 +1,71 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see .
+*/
+/** @file BrainWallet.h
+ * @author Gav Wood
+ * @date 2015
+ */
+
+#include "BrainWallet.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ui_BrainWallet.h"
+using namespace std;
+using namespace dev;
+using namespace az;
+using namespace eth;
+
+BrainWallet::BrainWallet(MainFace* _m):
+ Plugin(_m, "BrainWallet")
+{
+ QAction* a = new QAction("New Brain Wallet...", main());
+ QMenu* m = _m->findChild("menuTools");
+ m->addSeparator();
+ m->addAction(a);
+ connect(a, SIGNAL(triggered()), SLOT(create()));
+}
+
+BrainWallet::~BrainWallet()
+{
+}
+
+void BrainWallet::create()
+{
+ QDialog d;
+ Ui_BrainWallet u;
+ u.setupUi(&d);
+ d.setWindowTitle("New Brain Wallet");
+ connect(u.generate, &QPushButton::clicked, [&](){
+ boost::random_device d;
+ boost::random::uniform_int_distribution pickWord(0, WordList.size() - 1);
+ QString t;
+ for (int i = 0; i < 13; ++i)
+ t += (t.size() ? " " : "") + QString::fromStdString(WordList[pickWord(d)]);
+ u.seed->setPlainText(t);
+ });
+
+ if (d.exec() == QDialog::Accepted)
+ {
+ main()->keyManager().importBrain(u.seed->toPlainText().trimmed().toStdString(), u.name->text().toStdString(), u.hint->toPlainText().toStdString());
+ main()->noteKeysChanged();
+ }
+}
diff --git a/alethzero/BrainWallet.h b/alethzero/BrainWallet.h
new file mode 100644
index 000000000..6b472c6da
--- /dev/null
+++ b/alethzero/BrainWallet.h
@@ -0,0 +1,44 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see .
+*/
+/** @file BrainWallet.h
+ * @author Gav Wood
+ * @date 2015
+ */
+
+#pragma once
+
+#include "MainFace.h"
+
+namespace dev
+{
+namespace az
+{
+
+class BrainWallet: public QObject, public Plugin
+{
+ Q_OBJECT
+
+public:
+ BrainWallet(MainFace* _m);
+ ~BrainWallet();
+
+private slots:
+ void create();
+};
+
+}
+}
diff --git a/alethzero/BrainWallet.ui b/alethzero/BrainWallet.ui
new file mode 100644
index 000000000..d401e138a
--- /dev/null
+++ b/alethzero/BrainWallet.ui
@@ -0,0 +1,136 @@
+
+
+ BrainWallet
+
+
+
+ 0
+ 0
+ 511
+ 508
+
+
+
+ Dialog
+
+
+ -
+
+
+ <html><head/><body><p><span style=" font-weight:600;">WARNING: Brain wallets, or human-entropic seeds, are practically and cryptographically insecure. They're a terrible idea for protecteding anything of value and this functionality is here only as a toy.</span></p><p>That said, if you're intent on using one, make the phrase as long and random as you can. If you're sensible, you'll ask the internet for a list of words to memorise and use those. Write the phrase down on paper and bury it under an oak tree or something - if you forget it, you're screwed.</p></body></html>
+
+
+ true
+
+
+
+ -
+
+
+ Please name of this account here e.g. My Brain Wallet
+
+
+
+ -
+
+
+ Write your seed phrase here. Make it long and random. Don't ever forget it. If you want it to have any chance at being secure, ask a machine to select 13 dictionary words at random.
+
+
+
+ -
+
+
+ <html><head/><body><p>You can leave a hint here if you want; don't rely on it or there's little point in it being a <span style=" font-style:italic;">brain</span> wallet.</p></body></html>
+
+
+ true
+
+
+
+ -
+
+
+ An optional hint for the text above.
+
+
+
+ -
+
+
-
+
+
+ &Generate
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Cancel
+
+
+
+ -
+
+
+ &Create
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+ create
+ clicked()
+ BrainWallet
+ accept()
+
+
+ 462
+ 484
+
+
+ 449
+ 504
+
+
+
+
+ cancel
+ clicked()
+ BrainWallet
+ reject()
+
+
+ 381
+ 483
+
+
+ 351
+ 506
+
+
+
+
+
diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt
index 4d4dec71f..9bbb8f92d 100644
--- a/alethzero/CMakeLists.txt
+++ b/alethzero/CMakeLists.txt
@@ -40,6 +40,7 @@ qt5_wrap_ui(ui_GasPricing.h GasPricing.ui)
# Extensions
qt5_wrap_ui(ui_AllAccounts.h AllAccounts.ui)
qt5_wrap_ui(ui_LogPanel.h LogPanel.ui)
+qt5_wrap_ui(ui_BrainWallet.h BrainWallet.ui)
file(GLOB HEADERS "*.h")
@@ -52,7 +53,7 @@ endif ()
# eth_add_executable is defined in cmake/EthExecutableHelper.cmake
eth_add_executable(${EXECUTABLE}
ICON alethzero
- UI_RESOURCES alethzero.icns Main.ui Connect.ui Debugger.ui Transact.ui ExportState.ui GetPassword.ui GasPricing.ui AllAccounts.ui LogPanel.ui
+ UI_RESOURCES alethzero.icns Main.ui Connect.ui Debugger.ui Transact.ui ExportState.ui GetPassword.ui GasPricing.ui AllAccounts.ui LogPanel.ui BrainWallet.ui
WIN_RESOURCES alethzero.rc
)
diff --git a/alethzero/Context.h b/alethzero/Context.h
index 7dc2d5bc7..2968660c4 100644
--- a/alethzero/Context.h
+++ b/alethzero/Context.h
@@ -69,6 +69,7 @@ public:
virtual std::string render(dev::Address const& _a) const = 0;
virtual dev::Secret retrieveSecret(dev::Address const& _a) const = 0;
virtual dev::eth::KeyManager& keyManager() = 0;
+ virtual void noteKeysChanged() = 0;
virtual dev::u256 gasPrice() const = 0;
};
diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index 020afcec5..073593b8d 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -135,13 +135,13 @@
24
-