Gav Wood
10 years ago
11 changed files with 5365 additions and 33 deletions
@ -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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file BrainWallet.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2015 |
|||
*/ |
|||
|
|||
#include "BrainWallet.h" |
|||
#include <QMenu> |
|||
#include <QDialog> |
|||
#include <boost/random/random_device.hpp> |
|||
#include <boost/random/uniform_int_distribution.hpp> |
|||
#include <libdevcore/Log.h> |
|||
#include <libdevcrypto/WordList.h> |
|||
#include <libethcore/KeyManager.h> |
|||
#include <libethereum/Client.h> |
|||
#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<QMenu*>("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<unsigned> 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(); |
|||
} |
|||
} |
@ -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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file BrainWallet.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @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(); |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,136 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>BrainWallet</class> |
|||
<widget class="QDialog" name="BrainWallet"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>511</width> |
|||
<height>508</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Dialog</string> |
|||
</property> |
|||
<layout class="QVBoxLayout" name="verticalLayout"> |
|||
<item> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string><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></string> |
|||
</property> |
|||
<property name="wordWrap"> |
|||
<bool>true</bool> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLineEdit" name="name"> |
|||
<property name="placeholderText"> |
|||
<string>Please name of this account here e.g. My Brain Wallet</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QTextEdit" name="seed"> |
|||
<property name="placeholderText"> |
|||
<string>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.</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLabel" name="label_2"> |
|||
<property name="text"> |
|||
<string><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></string> |
|||
</property> |
|||
<property name="wordWrap"> |
|||
<bool>true</bool> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QTextEdit" name="hint"> |
|||
<property name="placeholderText"> |
|||
<string>An optional hint for the text above.</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<layout class="QHBoxLayout" name="horizontalLayout"> |
|||
<item> |
|||
<widget class="QPushButton" name="generate"> |
|||
<property name="text"> |
|||
<string>&Generate</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<spacer name="horizontalSpacer"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
<property name="sizeHint" stdset="0"> |
|||
<size> |
|||
<width>40</width> |
|||
<height>20</height> |
|||
</size> |
|||
</property> |
|||
</spacer> |
|||
</item> |
|||
<item> |
|||
<widget class="QPushButton" name="cancel"> |
|||
<property name="text"> |
|||
<string>Cancel</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QPushButton" name="create"> |
|||
<property name="text"> |
|||
<string>&Create</string> |
|||
</property> |
|||
<property name="default"> |
|||
<bool>true</bool> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>create</sender> |
|||
<signal>clicked()</signal> |
|||
<receiver>BrainWallet</receiver> |
|||
<slot>accept()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>462</x> |
|||
<y>484</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>449</x> |
|||
<y>504</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
<connection> |
|||
<sender>cancel</sender> |
|||
<signal>clicked()</signal> |
|||
<receiver>BrainWallet</receiver> |
|||
<slot>reject()</slot> |
|||
<hints> |
|||
<hint type="sourcelabel"> |
|||
<x>381</x> |
|||
<y>483</y> |
|||
</hint> |
|||
<hint type="destinationlabel"> |
|||
<x>351</x> |
|||
<y>506</y> |
|||
</hint> |
|||
</hints> |
|||
</connection> |
|||
</connections> |
|||
</ui> |
File diff suppressed because it is too large
@ -0,0 +1,31 @@ |
|||
/*
|
|||
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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file WordList.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2015 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include "Common.h" |
|||
|
|||
namespace dev |
|||
{ |
|||
|
|||
extern strings const WordList; |
|||
|
|||
} |
Loading…
Reference in new issue