Browse Source

Merge pull request #2764 from ethereum/tutorialtweaks

Various UI tweaks to make dangerous use harder.
cl-refactor
Gav Wood 10 years ago
parent
commit
f51337aa25
  1. 71
      alethzero/BrainWallet.cpp
  2. 44
      alethzero/BrainWallet.h
  3. 136
      alethzero/BrainWallet.ui
  4. 3
      alethzero/CMakeLists.txt
  5. 3
      alethzero/Connect.cpp
  6. 14
      alethzero/Connect.h
  7. 15
      alethzero/Context.cpp
  8. 11
      alethzero/Context.h
  9. 2
      alethzero/DappHost.cpp
  10. 8
      alethzero/DappHost.h
  11. 8
      alethzero/DappLoader.cpp
  12. 11
      alethzero/DappLoader.h
  13. 3
      alethzero/Debugger.cpp
  14. 9
      alethzero/Debugger.h
  15. 5
      alethzero/DownloadView.cpp
  16. 13
      alethzero/DownloadView.h
  17. 6
      alethzero/ExportState.cpp
  18. 16
      alethzero/ExportState.h
  19. 2
      alethzero/LogPanel.cpp
  20. 2
      alethzero/LogPanel.h
  21. 36
      alethzero/Main.ui
  22. 13
      alethzero/MainFace.h
  23. 89
      alethzero/MainWin.cpp
  24. 80
      alethzero/MainWin.h
  25. 7
      alethzero/MiningView.cpp
  26. 15
      alethzero/MiningView.h
  27. 3
      alethzero/NatspecHandler.cpp
  28. 8
      alethzero/NatspecHandler.h
  29. 3
      alethzero/OurWebThreeStubServer.cpp
  30. 31
      alethzero/OurWebThreeStubServer.h
  31. 8
      alethzero/Transact.cpp
  32. 15
      alethzero/Transact.h
  33. 4
      alethzero/WebPage.cpp
  34. 13
      alethzero/WebPage.h
  35. 2
      alethzero/main.cpp
  36. 118
      eth/main.cpp
  37. 2
      ethkey/KeyAux.h
  38. 5036
      libdevcrypto/WordList.cpp
  39. 31
      libdevcrypto/WordList.h
  40. 21
      libethcore/CommonJS.cpp
  41. 5
      libethcore/CommonJS.h
  42. 17
      libethcore/ICAP.cpp
  43. 5
      libethcore/ICAP.h
  44. 101
      libethcore/KeyManager.cpp
  45. 17
      libethcore/KeyManager.h
  46. 2
      libethereum/Executive.cpp
  47. 6
      libjsconsole/JSConsole.h
  48. 6
      libp2p/Common.h
  49. 1
      libweb3jsonrpc/JsonHelper.cpp
  50. 6
      libweb3jsonrpc/JsonHelper.h
  51. 3
      libweb3jsonrpc/WebThreeStubServer.cpp
  52. 21
      new.sh
  53. 41
      templates/dockplugin.cpp
  54. 56
      templates/dockplugin.h
  55. 36
      templates/dockplugin.ui
  56. 37
      templates/plugin.cpp
  57. 46
      templates/plugin.h

71
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 <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();
}
}

44
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 <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();
};
}
}

136
alethzero/BrainWallet.ui

@ -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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You can leave a hint here if you want; don't rely on it or there's little point in it being a &lt;span style=&quot; font-style:italic;&quot;&gt;brain&lt;/span&gt; wallet.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&amp;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>&amp;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>

3
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
)

3
alethzero/Connect.cpp

@ -20,9 +20,10 @@
*/
#include "Connect.h"
#include <libp2p/Host.h>
#include "ui_Connect.h"
using namespace dev;
using namespace az;
Connect::Connect(QWidget *parent) :
QDialog(parent),

14
alethzero/Connect.h

@ -25,9 +25,16 @@
#include <QList>
namespace Ui { class Connect; }
namespace dev { namespace p2p { class Host; } }
class Connect : public QDialog
namespace dev
{
namespace p2p { class Host; }
namespace az
{
class Connect: public QDialog
{
Q_OBJECT
@ -53,3 +60,6 @@ public:
private:
Ui::Connect* ui;
};
}
}

15
alethzero/Context.cpp

@ -25,7 +25,8 @@
#include <libethcore/Common.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace eth;
using namespace az;
NatSpecFace::~NatSpecFace()
{
@ -35,7 +36,7 @@ Context::~Context()
{
}
void setValueUnits(QComboBox* _units, QSpinBox* _value, u256 _v)
void dev::az::setValueUnits(QComboBox* _units, QSpinBox* _value, u256 _v)
{
initUnits(_units);
_units->setCurrentIndex(0);
@ -47,30 +48,30 @@ void setValueUnits(QComboBox* _units, QSpinBox* _value, u256 _v)
_value->setValue((unsigned)_v);
}
u256 fromValueUnits(QComboBox* _units, QSpinBox* _value)
u256 dev::az::fromValueUnits(QComboBox* _units, QSpinBox* _value)
{
return _value->value() * units()[units().size() - 1 - _units->currentIndex()].first;
}
void initUnits(QComboBox* _b)
void dev::az::initUnits(QComboBox* _b)
{
for (auto n = (unsigned)units().size(); n-- != 0; )
_b->addItem(QString::fromStdString(units()[n].second), n);
}
vector<KeyPair> keysAsVector(QList<KeyPair> const& keys)
vector<KeyPair> dev::az::keysAsVector(QList<KeyPair> const& keys)
{
auto list = keys.toStdList();
return {begin(list), end(list)};
}
bool sourceIsSolidity(string const& _source)
bool dev::az::sourceIsSolidity(string const& _source)
{
// TODO: Improve this heuristic
return (_source.substr(0, 8) == "contract" || _source.substr(0, 5) == "//sol");
}
bool sourceIsSerpent(string const& _source)
bool dev::az::sourceIsSerpent(string const& _source)
{
// TODO: Improve this heuristic
return (_source.substr(0, 5) == "//ser");

11
alethzero/Context.h

@ -30,7 +30,13 @@
class QComboBox;
class QSpinBox;
namespace dev { namespace eth { struct StateDiff; class KeyManager; } }
namespace dev
{
namespace eth { struct StateDiff; class KeyManager; }
namespace az
{
#define ETH_HTML_SMALL "font-size: small; "
#define ETH_HTML_MONO "font-family: Ubuntu Mono, Monospace, Lucida Console, Courier New; font-weight: bold; "
@ -69,7 +75,10 @@ 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;
};
}
}

2
alethzero/DappHost.cpp

@ -24,8 +24,8 @@
#include <microhttpd.h>
#include <boost/algorithm/string.hpp>
#include <libdevcore/Common.h>
using namespace dev;
using namespace az;
DappHost::DappHost(int _port, int _threads):
m_port(_port),

8
alethzero/DappHost.h

@ -29,6 +29,12 @@
struct MHD_Daemon;
struct MHD_Connection;
namespace dev
{
namespace az
{
/// DApp web server. Servers web content, resolves paths by hashes
class DappHost
{
@ -60,3 +66,5 @@ private:
std::map<QString, ManifestEntry const*> m_entriesByPath;
};
}
}

8
alethzero/DappLoader.cpp

@ -34,12 +34,12 @@
#include <libethereum/Client.h>
#include <libwebthree/WebThree.h>
#include "DappLoader.h"
using namespace dev;
using namespace dev::eth;
using namespace dev::crypto;
using namespace az;
using namespace eth;
using namespace crypto;
QString contentsOfQResource(std::string const& res);
namespace dev { namespace az { QString contentsOfQResource(std::string const& res); } }
DappLoader::DappLoader(QObject* _parent, WebThreeDirect* _web3, Address _nameReg):
QObject(_parent), m_web3(_web3), m_nameReg(_nameReg)

11
alethzero/DappLoader.h

@ -33,9 +33,12 @@
namespace dev
{
class WebThreeDirect;
class RLP;
}
class WebThreeDirect;
class RLP;
namespace az
{
struct ManifestEntry
{
@ -104,3 +107,5 @@ private:
std::string m_sessionKey;
};
}
}

3
alethzero/Debugger.cpp

@ -29,7 +29,8 @@
#include "ui_Debugger.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
Debugger::Debugger(Context* _c, QWidget* _parent):
QDialog(_parent),

9
alethzero/Debugger.h

@ -32,6 +32,12 @@
namespace Ui { class Debugger; }
namespace dev
{
namespace az
{
struct WorldState
{
uint64_t steps;
@ -101,3 +107,6 @@ private:
DebugSession m_session;
Context* m_context;
};
}
}

5
alethzero/DownloadView.cpp

@ -20,15 +20,14 @@
*/
#include "DownloadView.h"
#include <QtWidgets>
#include <QtCore>
#include <libethereum/DownloadMan.h>
#include "Grapher.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
SyncView::SyncView(QWidget* _p): QWidget(_p)
{

13
alethzero/DownloadView.h

@ -31,9 +31,13 @@
#include <libethereum/Client.h>
#endif
namespace dev { namespace eth {
class Client;
}}
namespace dev
{
namespace eth { class Client; }
namespace az
{
class SyncView: public QWidget
{
@ -54,3 +58,6 @@ private:
unsigned m_lastSyncCount = 0;
bool m_wasEstimate = false;
};
}
}

6
alethzero/ExportState.cpp

@ -25,10 +25,10 @@
#include <libethereum/Client.h>
#include "MainWin.h"
#include "ui_ExportState.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
ExportStateDialog::ExportStateDialog(Main* _parent):
QDialog(_parent),
@ -46,7 +46,7 @@ ExportStateDialog::~ExportStateDialog()
{
}
dev::eth::Client* ExportStateDialog::ethereum() const
Client* ExportStateDialog::ethereum() const
{
return m_main->ethereum();
}

16
alethzero/ExportState.h

@ -26,7 +26,14 @@
#include <libethcore/Common.h>
namespace Ui { class ExportState; }
namespace dev { namespace eth { class Client; } }
namespace dev
{
namespace eth { class Client; }
namespace az
{
class Main;
@ -44,7 +51,7 @@ private slots:
void on_saveButton_clicked();
private:
dev::eth::Client* ethereum() const;
eth::Client* ethereum() const;
void fillBlocks();
void fillContracts();
void generateJSON();
@ -53,5 +60,8 @@ private:
std::unique_ptr<Ui::ExportState> ui;
Main* m_main;
int m_recentBlocks = 0;
dev::eth::BlockNumber m_block = dev::eth::LatestBlock;
eth::BlockNumber m_block = eth::LatestBlock;
};
}
}

2
alethzero/LogPanel.cpp

@ -14,7 +14,7 @@
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 LogPanel.h
/** @file LogPanel.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/

2
alethzero/LogPanel.h

@ -14,7 +14,7 @@
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 AllAccounts.h
/** @file LogPanel.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/

36
alethzero/Main.ui

@ -135,13 +135,13 @@
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<widget class="QMenu" name="menuFile">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="quit"/>
</widget>
<widget class="QMenu" name="menu_Network">
<widget class="QMenu" name="menuNetwork">
<property name="title">
<string>&amp;Network</string>
</property>
@ -153,7 +153,7 @@
<addaction name="connect"/>
<addaction name="hermitMode"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<widget class="QMenu" name="menuTools">
<property name="title">
<string>&amp;Tools</string>
</property>
@ -175,13 +175,13 @@
<addaction name="separator"/>
<addaction name="exportState"/>
</widget>
<widget class="QMenu" name="menu_Help">
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="about"/>
</widget>
<widget class="QMenu" name="menu_Debug">
<widget class="QMenu" name="menuSpecial">
<property name="title">
<string>&amp;Special</string>
</property>
@ -202,7 +202,7 @@
<addaction name="confirm"/>
<addaction name="rewindChain"/>
</widget>
<widget class="QMenu" name="menu_View">
<widget class="QMenu" name="menuView">
<property name="title">
<string>&amp;View</string>
</property>
@ -225,22 +225,22 @@
<addaction name="debugDumpStatePre"/>
<addaction name="dumpBlockState"/>
</widget>
<widget class="QMenu" name="menu_Config">
<widget class="QMenu" name="menuConfig">
<property name="title">
<string>&amp;Config</string>
</property>
<addaction name="gasPrices"/>
<addaction name="sentinel"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_View"/>
<addaction name="menu_Network"/>
<addaction name="menu_Tools"/>
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuNetwork"/>
<addaction name="menuTools"/>
<addaction name="menuWhispe"/>
<addaction name="menuDebug"/>
<addaction name="menu_Config"/>
<addaction name="menu_Help"/>
<addaction name="menu_Debug"/>
<addaction name="menuConfig"/>
<addaction name="menuHelp"/>
<addaction name="menuSpecial"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="dockWidget_3">
@ -641,7 +641,7 @@
<number>0</number>
</property>
<item>
<widget class="MiningView" name="miningView" native="true"/>
<widget class="dev::az::MiningView" name="miningView" native="true"/>
</item>
</layout>
</widget>
@ -940,7 +940,7 @@ font-size: 14pt</string>
<number>0</number>
</property>
<item>
<widget class="SyncView" name="downloadView" native="true"/>
<widget class="dev::az::SyncView" name="downloadView" native="true"/>
</item>
</layout>
</widget>
@ -1617,13 +1617,13 @@ font-size: 14pt</string>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>MiningView</class>
<class>dev::az::MiningView</class>
<extends>QWidget</extends>
<header>MiningView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SyncView</class>
<class>dev::az::SyncView</class>
<extends>QWidget</extends>
<header>DownloadView.h</header>
<container>1</container>

13
alethzero/MainFace.h

@ -47,6 +47,14 @@ class Plugin;
using WatchHandler = std::function<void(dev::eth::LocalisedLogEntries const&)>;
class AccountNamer
{
public:
virtual std::string toName(Address const&) const { return std::string(); }
virtual Address toAddress(std::string const&) const { return Address(); }
virtual Addresses knownAddresses() const { return Addresses(); }
};
class MainFace: public QMainWindow, public Context
{
public:
@ -66,6 +74,11 @@ public:
virtual unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f) = 0;
virtual unsigned installWatch(dev::h256 const& _tf, WatchHandler const& _f) = 0;
// Account naming API
virtual void install(AccountNamer* _adopt) = 0;
virtual void uninstall(AccountNamer* _kill) = 0;
virtual void noteAddressesChanged() = 0;
protected:
template <class F> void forEach(F const& _f) { for (auto const& p: m_plugins) _f(p.second); }
std::shared_ptr<Plugin> takePlugin(std::string const& _name) { auto it = m_plugins.find(_name); std::shared_ptr<Plugin> ret; if (it != m_plugins.end()) { ret = it->second; m_plugins.erase(it); } return ret; }

89
alethzero/MainWin.cpp

@ -76,6 +76,7 @@
#include "ExportState.h"
#include "AllAccounts.h"
#include "LogPanel.h"
#include "BrainWallet.h"
#include "ui_Main.h"
#include "ui_GetPassword.h"
#include "ui_GasPricing.h"
@ -86,32 +87,7 @@ using namespace p2p;
using namespace eth;
namespace js = json_spirit;
string Main::fromRaw(h256 _n, unsigned* _inc)
{
if (_n)
{
string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return string();
if (l != string::npos)
{
auto p = s.find_first_not_of('\0', l);
if (!(p == string::npos || (_inc && p == 31)))
return string();
if (_inc)
*_inc = (byte)s[31];
s.resize(l);
}
for (auto i: s)
if (i < 32)
return string();
return s;
}
return string();
}
QString contentsOfQResource(string const& res)
QString dev::az::contentsOfQResource(string const& res)
{
QFile file(QString::fromStdString(res));
if (!file.open(QFile::ReadOnly))
@ -183,7 +159,7 @@ Main::Main(QWidget* _parent):
QMessageBox::warning(nullptr, "Try again", "You entered two different passwords - please enter the same password twice.", QMessageBox::Ok);
}
m_keyManager.create(password.toStdString());
m_keyManager.import(Secret::random(), "Default identity");
m_keyManager.import(ICAP::createDirect(), "Default identity");
}
#if ETH_DEBUG
@ -255,7 +231,7 @@ Main::Main(QWidget* _parent):
ethereum()->setDefault(LatestBlock);
m_vmSelectionGroup = new QActionGroup{ui->menu_Debug};
m_vmSelectionGroup = new QActionGroup{ui->menuDebug};
m_vmSelectionGroup->addAction(ui->vmInterpreter);
m_vmSelectionGroup->addAction(ui->vmJIT);
m_vmSelectionGroup->addAction(ui->vmSmart);
@ -294,6 +270,7 @@ Main::Main(QWidget* _parent):
loadPlugin<dev::az::AllAccounts>();
#endif
loadPlugin<dev::az::LogPanel>();
loadPlugin<dev::az::BrainWallet>();
}
Main::~Main()
@ -307,6 +284,48 @@ Main::~Main()
writeSettings();
}
string Main::fromRaw(h256 const&_n, unsigned* _inc)
{
if (_n)
{
string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return string();
if (l != string::npos)
{
auto p = s.find_first_not_of('\0', l);
if (!(p == string::npos || (_inc && p == 31)))
return string();
if (_inc)
*_inc = (byte)s[31];
s.resize(l);
}
for (auto i: s)
if (i < 32)
return string();
return s;
}
return string();
}
void Main::install(AccountNamer* _adopt)
{
m_namers.insert(_adopt);
refreshAll();
}
void Main::uninstall(AccountNamer* _kill)
{
m_namers.erase(_kill);
refreshAll();
}
void Main::noteAddressesChanged()
{
refreshAll();
}
bool Main::confirm() const
{
return ui->natSpec->isChecked();
@ -636,6 +655,13 @@ std::string Main::pretty(dev::Address const& _a) const
if (!n.empty())
return n;
}
for (auto i: m_namers)
{
auto n = i->toName(_a);
if (!n.empty())
return n;
}
return string();
}
@ -668,6 +694,11 @@ pair<Address, bytes> Main::fromString(std::string const& _n) const
if (a)
return make_pair(a, bytes());
}
for (auto i: m_namers)
if (auto a = i->toAddress(_n))
return make_pair(a, bytes());
if (n.size() == 40)
{
try
@ -1177,7 +1208,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);

80
alethzero/MainWin.h

@ -50,16 +50,24 @@ namespace Ui {
class Main;
}
namespace dev { namespace eth {
class Client;
class State;
}}
namespace jsonrpc {
class HttpServer;
}
class QWebEnginePage;
namespace dev
{
namespace eth
{
class Client;
class State;
}
namespace az
{
class OurWebThreeStubServer;
class DappLoader;
class DappHost;
@ -67,7 +75,7 @@ struct Dapp;
QString contentsOfQResource(std::string const& res);
class Main: public dev::az::MainFace
class Main: public MainFace
{
Q_OBJECT
@ -75,27 +83,33 @@ public:
explicit Main(QWidget *parent = 0);
~Main();
dev::WebThreeDirect* web3() const override { return m_webThree.get(); }
dev::eth::Client* ethereum() const override { return m_webThree->ethereum(); }
std::shared_ptr<dev::shh::WhisperHost> whisper() const override { return m_webThree->whisper(); }
WebThreeDirect* web3() const override { return m_webThree.get(); }
eth::Client* ethereum() const override { return m_webThree->ethereum(); }
std::shared_ptr<shh::WhisperHost> whisper() const override { return m_webThree->whisper(); }
bool confirm() const;
NatSpecFace* natSpec() { return &m_natSpecDB; }
std::string pretty(dev::Address const& _a) const override;
std::string prettyU256(dev::u256 const& _n) const override;
std::string prettyU256(u256 const& _n) const override;
std::string render(dev::Address const& _a) const override;
std::pair<dev::Address, dev::bytes> fromString(std::string const& _a) const override;
std::string renderDiff(dev::eth::StateDiff const& _d) const override;
std::pair<Address, bytes> fromString(std::string const& _a) const override;
std::string renderDiff(eth::StateDiff const& _d) const override;
QList<dev::KeyPair> owned() const { return m_myIdentities; }
QList<KeyPair> owned() const { return m_myIdentities; }
dev::u256 gasPrice() const override;
u256 gasPrice() const override;
dev::eth::KeyManager& keyManager() override { return m_keyManager; }
eth::KeyManager& keyManager() override { return m_keyManager; }
void noteKeysChanged() override { refreshBalances(); }
bool doConfirm();
dev::Secret retrieveSecret(dev::Address const& _address) const override;
Secret retrieveSecret(Address const& _address) const override;
// Account naming API.
void install(AccountNamer* _adopt) override;
void uninstall(AccountNamer* _kill) override;
void noteAddressesChanged() override;
public slots:
void load(QString _file);
@ -199,18 +213,18 @@ signals:
void poll();
private:
template <class P> void loadPlugin() { dev::az::Plugin* p = new P(this); initPlugin(p); }
void initPlugin(dev::az::Plugin* _p);
void finalisePlugin(dev::az::Plugin* _p);
template <class P> void loadPlugin() { Plugin* p = new P(this); initPlugin(p); }
void initPlugin(Plugin* _p);
void finalisePlugin(Plugin* _p);
void unloadPlugin(std::string const& _name);
void debugDumpState(int _add);
dev::p2p::NetworkPreferences netPrefs() const;
p2p::NetworkPreferences netPrefs() const;
QString lookup(QString const& _n) const;
dev::Address getNameReg() const;
dev::Address getCurrencies() const;
Address getNameReg() const;
Address getCurrencies() const;
void updateFee();
void readSettings(bool _skipGeometry = false);
@ -218,8 +232,8 @@ private:
void setPrivateChain(QString const& _private, bool _forceConfigure = false);
unsigned installWatch(dev::eth::LogFilter const& _tf, dev::az::WatchHandler const& _f) override;
unsigned installWatch(dev::h256 const& _tf, dev::az::WatchHandler const& _f) override;
unsigned installWatch(eth::LogFilter const& _tf, WatchHandler const& _f) override;
unsigned installWatch(h256 const& _tf, WatchHandler const& _f) override;
void uninstallWatch(unsigned _w);
void keysChanged();
@ -244,26 +258,25 @@ private:
void refreshAll();
void refreshPending();
void refreshAccounts();
void refreshBlockCount();
void refreshBalances();
void setBeneficiary(dev::Address const& _b);
void setBeneficiary(Address const& _b);
std::string getPassword(std::string const& _title, std::string const& _for, std::string* _hint = nullptr, bool* _ok = nullptr);
std::unique_ptr<Ui::Main> ui;
std::unique_ptr<dev::WebThreeDirect> m_webThree;
std::unique_ptr<WebThreeDirect> m_webThree;
std::map<unsigned, dev::az::WatchHandler> m_handlers;
std::map<unsigned, WatchHandler> m_handlers;
unsigned m_nameRegFilter = (unsigned)-1;
unsigned m_currenciesFilter = (unsigned)-1;
unsigned m_balancesFilter = (unsigned)-1;
QByteArray m_networkConfig;
QStringList m_servers;
QList<dev::KeyPair> m_myIdentities;
dev::eth::KeyManager m_keyManager;
QList<KeyPair> m_myIdentities;
eth::KeyManager m_keyManager;
QString m_privateChain;
dev::Address m_nameReg;
dev::Address m_beneficiary;
@ -275,7 +288,7 @@ private:
std::unique_ptr<jsonrpc::HttpServer> m_httpConnector;
std::unique_ptr<OurWebThreeStubServer> m_server;
static std::string fromRaw(dev::h256 _n, unsigned* _inc = nullptr);
static std::string fromRaw(h256 const& _n, unsigned* _inc = nullptr);
NatspecHandler m_natSpecDB;
Transact* m_transact;
@ -284,4 +297,9 @@ private:
QWebEnginePage* m_webPage;
Connect m_connect;
std::unordered_set<AccountNamer*> m_namers;
};
}
}

7
alethzero/MiningView.cpp

@ -28,17 +28,12 @@
using namespace std;
using namespace lb;
// do *not* use eth since unsigned conflicts with Qt's global unit definition
// using namespace dev;
using namespace dev::az;
using namespace dev::eth;
// types
using dev::eth::MineInfo;
using dev::eth::WorkingProgress;
// functions
using dev::toString;
using dev::trimFront;

15
alethzero/MiningView.h

@ -31,9 +31,16 @@
#include <libethereum/Client.h>
#endif
namespace dev { namespace eth {
namespace dev
{
namespace eth
{
struct MineInfo;
}}
}
namespace az
{
class MiningView: public QWidget
{
@ -59,3 +66,7 @@ private:
double m_lastBest = 1e31;
bool m_haveReset = false;
};
}
}

3
alethzero/NatspecHandler.cpp

@ -30,7 +30,8 @@
#include <libdevcore/SHA3.h>
#include <libethereum/Defaults.h>
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
using namespace std;
namespace fs = boost::filesystem;

8
alethzero/NatspecHandler.h

@ -27,6 +27,11 @@
#include <libdevcore/FixedHash.h>
#include "Context.h"
namespace dev
{
namespace az
{
class NatspecHandler: public NatSpecFace
{
public:
@ -52,3 +57,6 @@ class NatspecHandler: public NatSpecFace
ldb::DB* m_db = nullptr;
Json::Reader m_reader;
};
}
}

3
alethzero/OurWebThreeStubServer.cpp

@ -27,7 +27,8 @@
#include "MainWin.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
OurWebThreeStubServer::OurWebThreeStubServer(
jsonrpc::AbstractServerConnector& _conn,

31
alethzero/OurWebThreeStubServer.h

@ -27,9 +27,15 @@
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include <libweb3jsonrpc/AccountHolder.h>
namespace dev
{
namespace az
{
class Main;
class OurAccountHolder: public QObject, public dev::eth::AccountHolder
class OurAccountHolder: public QObject, public eth::AccountHolder
{
Q_OBJECT
@ -47,27 +53,24 @@ protected:
private:
bool showAuthenticationPopup(std::string const& _title, std::string const& _text);
bool showCreationNotice(dev::eth::TransactionSkeleton const& _t, bool _toProxy);
bool showSendNotice(dev::eth::TransactionSkeleton const& _t, bool _toProxy);
bool showUnknownCallNotice(dev::eth::TransactionSkeleton const& _t, bool _toProxy);
bool showCreationNotice(eth::TransactionSkeleton const& _t, bool _toProxy);
bool showSendNotice(eth::TransactionSkeleton const& _t, bool _toProxy);
bool showUnknownCallNotice(eth::TransactionSkeleton const& _t, bool _toProxy);
bool validateTransaction(dev::eth::TransactionSkeleton const& _t, bool _toProxy);
bool validateTransaction(eth::TransactionSkeleton const& _t, bool _toProxy);
std::queue<dev::eth::TransactionSkeleton> m_queued;
dev::Mutex x_queued;
std::queue<eth::TransactionSkeleton> m_queued;
Mutex x_queued;
Main* m_main;
};
class OurWebThreeStubServer: public QObject, public dev::WebThreeStubServer
class OurWebThreeStubServer: public QObject, public WebThreeStubServer
{
Q_OBJECT
public:
OurWebThreeStubServer(
jsonrpc::AbstractServerConnector& _conn,
Main* main
);
OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, Main* main);
virtual std::string shh_newIdentity() override;
@ -77,3 +80,7 @@ signals:
private:
Main* m_main;
};
}
}

8
alethzero/Transact.cpp

@ -41,7 +41,6 @@
#include <libethereum/Client.h>
#include <libethereum/Utility.h>
#include <libethcore/KeyManager.h>
#if ETH_SERPENT
#include <libserpent/funcs.h>
#include <libserpent/util.h>
@ -50,7 +49,8 @@
#include "ui_Transact.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace az;
using namespace eth;
Transact::Transact(Context* _c, QWidget* _parent):
QDialog(_parent),
@ -206,7 +206,7 @@ void Transact::on_copyUnsigned_clicked()
qApp->clipboard()->setText(QString::fromStdString(toHex(t.rlp())));
}
static std::string toString(TransactionException _te)
/*static std::string toString(TransactionException _te)
{
switch (_te)
{
@ -223,7 +223,7 @@ static std::string toString(TransactionException _te)
case TransactionException::StackUnderflow: return "VM Error: Stack underflow";
default:; return std::string();
}
}
}*/
#if ETH_SOLIDITY
static string getFunctionHashes(dev::solidity::CompilerStack const& _compiler, string const& _contractName)

15
alethzero/Transact.h

@ -30,8 +30,15 @@
#include "Context.h"
namespace Ui { class Transact; }
namespace dev { namespace eth { class Client; } }
namespace dev { namespace solidity { class CompilerStack; } }
namespace dev
{
namespace eth { class Client; }
namespace solidity { class CompilerStack; }
namespace az
{
struct GasRequirements
{
@ -99,3 +106,7 @@ private:
NatSpecFace* m_natSpecDB = nullptr;
bool m_allGood = false;
};
}
}

4
alethzero/WebPage.cpp

@ -20,8 +20,10 @@
*/
#include "WebPage.h"
using namespace dev;
using namespace az;
void WebPage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel _level, const QString& _message, int _lineNumber, const QString& _sourceID)
void WebPage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel _level, QString const& _message, int _lineNumber, QString const& _sourceID)
{
QString prefix = _level == QWebEnginePage::ErrorMessageLevel ? "error" : _level == QWebEnginePage::WarningMessageLevel ? "warning" : "";
emit consoleMessage(QString("%1(%2:%3):%4").arg(prefix).arg(_sourceID).arg(_lineNumber).arg(_message));

13
alethzero/WebPage.h

@ -27,14 +27,25 @@
#include <QtWebEngineWidgets/QWebEnginePage>
#pragma GCC diagnostic pop
namespace dev
{
namespace az
{
class WebPage: public QWebEnginePage
{
Q_OBJECT
public:
WebPage(QObject* _parent): QWebEnginePage(_parent) { }
WebPage(QObject* _parent): QWebEnginePage(_parent) {}
signals:
void consoleMessage(QString const& _msg);
protected:
void javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel _level, const QString& _message, int _lineNumber, const QString& _sourceID) override;
};
}
}

2
alethzero/main.cpp

@ -5,7 +5,7 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Q_INIT_RESOURCE(js);
Main w;
dev::az::Main w;
w.show();
return a.exec();

118
eth/main.cpp

@ -38,7 +38,7 @@
#include <libethereum/All.h>
#include <libethereum/BlockChainSync.h>
#include <libethcore/KeyManager.h>
#include <libethcore/ICAP.h>
#include <libwebthree/WebThree.h>
#if ETH_JSCONSOLE || !ETH_TRUE
#include <libjsconsole/JSLocalConsole.h>
@ -68,58 +68,17 @@ using dev::eth::Instruction;
static std::atomic<bool> g_silence = {false};
void interactiveHelp()
{
cout
<< "Commands:" << endl
<< " netstart <port> Starts the network subsystem on a specific port." << endl
<< " netstop Stops the network subsystem." << endl
<< " connect <addr> <port> Connects to a specific peer." << endl
<< " verbosity (<level>) Gets or sets verbosity level." << endl
<< " minestart Starts mining." << endl
<< " minestop Stops mining." << endl
<< " mineforce <enable> Forces mining, even when there are no transactions." << endl
<< " block Gives the current block height." << endl
<< " blockhashfromnumber <number> Gives the block hash with the givne number." << endl
<< " numberfromblockhash <hash> Gives the block number with the given hash." << endl
<< " blockqueue Gives the current block queue status." << endl
<< " findblock <hash> Searches for the block in the blockchain and blockqueue." << endl
<< " firstunknown Gives the first unknown block from the blockqueue." << endl
<< " retryunknown retries to import all unknown blocks from the blockqueue." << endl
<< " accounts Gives information on all owned accounts (balances, mining beneficiary and default signer)." << endl
<< " newaccount <name> Creates a new account with the given name." << endl
<< " transact Execute a given transaction." << endl
<< " transactnonce Execute a given transaction with a specified nonce." << endl
<< " txcreate Execute a given contract creation transaction." << endl
<< " send Execute a given transaction with current secret." << endl
<< " contract Create a new contract with current secret." << endl
<< " peers List the peers that are connected" << endl
#if ETH_FATDB || !ETH_TRUE
<< " listaccounts List the accounts on the network." << endl
<< " listcontracts List the contracts on the network." << endl
<< " balanceat <address> Gives the balance of the given account." << endl
<< " balanceatblock <address> <blocknumber> Gives the balance of the given account." << endl
<< " storageat <address> Gives the storage of the given account." << endl
<< " storageatblock <address> <blocknumber> Gives the storahe of the given account at a given blocknumber." << endl
<< " codeat <address> Gives the code of the given account." << endl
#endif
<< " setsigningkey <addr> Set the address with which to sign transactions." << endl
<< " setaddress <addr> Set the coinbase (mining payout) address." << endl
<< " exportconfig <path> Export the config (.RLP) to the path provided." << endl
<< " importconfig <path> Import the config (.RLP) from the path provided." << endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " reprocess <block> Reprocess a given block." << endl
<< " dumptrace <block> <index> <filename> <format> Dumps a transaction trace" << endl << "to <filename>. <format> should be one of pretty, standard, standard+." << endl
<< " dumpreceipt <block> <index> Dumps a transation receipt." << endl
<< " hashrate Print the current hashrate in hashes per second if the client is mining." << endl
<< " exit Exits the application." << endl;
}
void help()
{
cout
<< "Usage eth [OPTIONS]" << endl
<< "Options:" << endl << endl
<< "Operating mode (default is non-interactive node):" << endl
#if ETH_JSCONSOLE || !ETH_TRUE
<< " console Enter interactive console mode (default: non-interactive)." << endl
<< " import <file> Import file as a concatenated series of blocks." << endl
<< " export <file> Export file as a concatenated series of blocks." << endl
#endif
<< "Client mode (default):" << endl
<< " --olympic Use the Olympic (0.9) protocol." << endl
<< " --frontier Use the Frontier (1.0) protocol." << endl
@ -127,9 +86,6 @@ void help()
<< " --genesis-json <file> Import the genesis block information from the given json file." << endl
<< endl
<< " -o,--mode <full/peer> Start a full node or a peer node (default: full)." << endl
#if ETH_JSCONSOLE || !ETH_TRUE
<< " -i,--interactive Enter interactive mode (default: non-interactive)." << endl
#endif
<< endl
#if ETH_JSONRPC || !ETH_TRUE
<< " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
@ -169,7 +125,8 @@ void help()
<< endl
<< "Client networking:" << endl
<< " --client-name <name> Add a name to your client's version string (default: blank)." << endl
<< " -b,--bootstrap Connect to the default Ethereum peerserver." << endl
<< " --bootstrap Connect to the default Ethereum peerservers (default unless --no-discovery used)." << endl
<< " --no-bootstrap Do not connect to the default Ethereum peerservers (default only when --no-discovery is used)." << endl
<< " -x,--peers <number> Attempt to connect to given number of peers (default: 11)." << endl
<< " --peer-stretch <number> Accepted connection multiplier (default: 7)." << endl
@ -187,7 +144,7 @@ void help()
// << " trusted Keep connected at all times." << endl
// << " --trust-peers <filename> Text list of publickeys." << endl
<< " --no-discovery Disable Node discovery." << endl
<< " --no-discovery Disable Node discovery, implies --no-bootstrap." << endl
<< " --pin Only accept or connect to trusted peers." << endl
<< " --hermit Equivalent to --no-discovery --pin." << endl
<< " --sociable Forces discovery and no pinning." << endl
@ -198,9 +155,8 @@ void help()
<< " --structured-logging Enable structured logging (default output to stdout)." << endl
<< " --structured-logging-format <format> Set the structured logging time format." << endl
<< " --structured-logging-url <URL> Set the structured logging destination (currently only file:// supported)." << endl
<< endl
<< "Import/export modes:" << endl
<< " -I,--import <file> Import file as a concatenated series of blocks and exit." << endl
<< " -E,--export <file> Export file as a concatenated series of blocks and exit." << endl
<< " --from <n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
<< " --to <n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
<< " --only <n> Equivalent to --export-from n --export-to n." << endl
@ -310,13 +266,17 @@ void stopMiningAfterXBlocks(eth::Client* _c, unsigned _start, unsigned& io_minin
this_thread::sleep_for(chrono::milliseconds(100));
}
void interactiveMode(eth::Client*, std::shared_ptr<eth::TrivialGasPricer>, WebThreeDirect&, KeyManager&, string&, string&, function<string(string const&)>, function<string(Address const&)>, NetworkPreferences, Address, Address, TransactionPriority) {}
int main(int argc, char** argv)
{
// Init defaults
Defaults::get();
#if ETH_DEBUG
g_logVerbosity = 4;
#else
g_logVerbosity = 1;
#endif
/// Operating mode.
OperationMode mode = OperationMode::Node;
string dbPath;
@ -359,7 +319,7 @@ int main(int argc, char** argv)
HostPeerPreferences hprefs;
unsigned peers = hprefs.idealPeerCount;
unsigned peerStretch = hprefs.stretchPeerCount;
bool bootstrap = false;
bool bootstrap = true;
bool disableDiscovery = false;
bool pinning = false;
bool enableDiscovery = false;
@ -381,7 +341,7 @@ int main(int argc, char** argv)
string structuredLoggingURL;
/// Transaction params
TransactionPriority priority = TransactionPriority::Medium;
// TransactionPriority priority = TransactionPriority::Medium;
// double etherPrice = 30.679;
// double blockFees = 15.0;
u256 askPrice = c_defaultGasPrice;
@ -444,14 +404,14 @@ int main(int argc, char** argv)
passwordsToNote.push_back(argv[++i]);
else if (arg == "--master" && i + 1 < argc)
masterPassword = argv[++i];
else if ((arg == "-I" || arg == "--import") && i + 1 < argc)
else if ((arg == "-I" || arg == "--import" || arg == "import") && i + 1 < argc)
{
mode = OperationMode::Import;
filename = argv[++i];
}
else if (arg == "--dont-check")
safeImport = true;
else if ((arg == "-E" || arg == "--export") && i + 1 < argc)
else if ((arg == "-E" || arg == "--export" || arg == "export") && i + 1 < argc)
{
mode = OperationMode::Export;
filename = argv[++i];
@ -645,7 +605,7 @@ int main(int argc, char** argv)
return -1;
}
}
else if ((arg == "-P" || arg == "--priority") && i + 1 < argc)
/* else if ((arg == "-P" || arg == "--priority") && i + 1 < argc)
{
string m = boost::to_lower_copy(string(argv[++i]));
if (m == "lowest")
@ -666,7 +626,7 @@ int main(int argc, char** argv)
cerr << "Unknown " << arg << " option: " << m << endl;
return -1;
}
}
}*/
else if ((arg == "-m" || arg == "--mining") && i + 1 < argc)
{
string m = argv[++i];
@ -685,8 +645,13 @@ int main(int argc, char** argv)
}
else if (arg == "-b" || arg == "--bootstrap")
bootstrap = true;
else if (arg == "--no-bootstrap")
bootstrap = false;
else if (arg == "--no-discovery")
{
disableDiscovery = true;
bootstrap = false;
}
else if (arg == "--pin")
pinning = true;
else if (arg == "--hermit")
@ -708,7 +673,7 @@ int main(int argc, char** argv)
jsonAdmin = argv[++i];
#endif
#if ETH_JSCONSOLE || !ETH_TRUE
else if (arg == "-i" || arg == "--interactive" || arg == "--console")
else if (arg == "-i" || arg == "--interactive" || arg == "--console" || arg == "console")
useConsole = true;
#endif
else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
@ -777,7 +742,7 @@ int main(int argc, char** argv)
if (c_network == eth::Network::Olympic)
cout << "Welcome to Olympic!" << endl;
else if (c_network == eth::Network::Frontier)
cout << "Welcome to the " EthMaroonBold "Frontier" EthReset "!" << endl;
cout << "Beware. You're entering the " EthMaroonBold "Frontier" EthReset "!" << endl;
}
m.execute();
@ -993,7 +958,7 @@ int main(int argc, char** argv)
if (keyManager.accounts().empty())
{
h128 uuid = keyManager.import(Secret::random(), "Default key");
h128 uuid = keyManager.import(ICAP::createDirect(), "Default key");
if (!beneficiary)
beneficiary = keyManager.address(uuid);
if (!signingKey)
@ -1019,8 +984,14 @@ int main(int argc, char** argv)
c->setNetworkId(networkId);
}
cout << "Transaction Signer: " << signingKey << endl;
cout << "Mining Benefactor: " << beneficiary << endl;
auto renderFullAddress = [&](Address const& _a) -> std::string
{
return ICAP(_a).encoded() + " (" + toUUID(keyManager.uuid(_a)) + " - " + toHex(_a.ref().cropped(0, 4)) + ")";
};
cout << "Transaction Signer: " << renderFullAddress(signingKey) << endl;
cout << "Mining Beneficiary: " << renderFullAddress(beneficiary) << endl;
cout << "Foundation: " << renderFullAddress(Address("de0b295669a9fd93d5f28d9ec85e40f4cb697bae")) << endl;
if (bootstrap || !remoteHost.empty() || disableDiscovery)
{
@ -1028,7 +999,7 @@ int main(int argc, char** argv)
cout << "Node ID: " << web3.enode() << endl;
}
else
cout << "Networking disabled. To start, use netstart or pass -b or a remote host." << endl;
cout << "Networking disabled. To start, use netstart or pass --bootstrap or a remote host." << endl;
if (useConsole && jsonRPCURL == -1)
jsonRPCURL = SensibleHttpPort;
@ -1061,9 +1032,7 @@ int main(int argc, char** argv)
signal(SIGTERM, &sighandler);
signal(SIGINT, &sighandler);
if (interactive)
interactiveMode(c, gasPricer, web3, keyManager, logbuf, additional, getPassword, getAccountPassword, netPrefs, beneficiary, signingKey, priority);
else if (c)
if (c)
{
unsigned n = c->blockChain().details().number;
if (mining)
@ -1075,11 +1044,8 @@ int main(int argc, char** argv)
shared_ptr<dev::WebThreeStubServer> rpcServer = make_shared<dev::WebThreeStubServer>(*console.connector(), web3, make_shared<SimpleAccountHolder>([&](){ return web3.ethereum(); }, getAccountPassword, keyManager), vector<KeyPair>(), keyManager, *gasPricer);
string sessionKey = rpcServer->newSession(SessionPermissions{{Privilege::Admin}});
console.eval("web3.admin.setSessionKey('" + sessionKey + "')");
while (!g_exit)
{
console.readExpression();
while (console.readExpression())
stopMiningAfterXBlocks(c, n, mining);
}
rpcServer->StopListening();
#endif
}

2
ethkey/KeyAux.h

@ -505,7 +505,7 @@ public:
if (Address a = wallet.address(u))
{
cout << toUUID(u) << " " << a.abridged();
cout << " (Not ICAP) ";
cout << " " << ICAP(a).encoded();
cout << " " << wallet.accountName(a) << endl;
}
for (auto const& u: bare)

5036
libdevcrypto/WordList.cpp

File diff suppressed because it is too large

31
libdevcrypto/WordList.h

@ -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;
}

21
libethcore/CommonJS.cpp

@ -22,16 +22,27 @@
*/
#include "CommonJS.h"
#include "ICAP.h"
namespace dev
{
Address toAddress(std::string const& _sn)
Address jsToAddress(std::string const& _s)
{
if (_sn.size() == 40)
return Address(fromHex(_sn));
else
return Address();
try
{
eth::ICAP i = eth::ICAP::decoded(_s);
return i.direct();
}
catch (eth::InvalidICAP&) {}
try
{
auto b = fromHex(_s.substr(0, 2) == "0x" ? _s.substr(2) : _s, WhenError::Throw);
if (b.size() == 20)
return Address(b);
}
catch (BadHexCharacter&) {}
BOOST_THROW_EXCEPTION(InvalidAddress());
}
std::string prettyU256(u256 _n, bool _abridged)

5
libethcore/CommonJS.h

@ -33,8 +33,7 @@
namespace dev
{
/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40).
Address toAddress(std::string const& _a);
DEV_SIMPLE_EXCEPTION(InvalidAddress);
/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length.
inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
@ -43,7 +42,7 @@ inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::P
inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed<sizeof(dev::Secret)>(_s); Secret ret(d); d.ref().cleanse(); return ret; }
/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length.
inline Address jsToAddress(std::string const& _s) { return jsToFixed<sizeof(dev::Address)>(_s); }
Address jsToAddress(std::string const& _s);
/// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256.
std::string prettyU256(u256 _n, bool _abridged = true);

17
libethcore/ICAP.cpp

@ -64,6 +64,17 @@ std::pair<string, string> ICAP::fromIBAN(std::string _iban)
return make_pair(c, d);
}
Secret ICAP::createDirect()
{
Secret ret;
while (true)
{
ret = Secret::random();
if (!toAddress(ret)[0])
return ret;
}
}
ICAP ICAP::decoded(std::string const& _encoded)
{
ICAP ret;
@ -72,7 +83,7 @@ ICAP ICAP::decoded(std::string const& _encoded)
std::tie(country, data) = fromIBAN(_encoded);
if (country != "XE")
BOOST_THROW_EXCEPTION(InvalidICAP());
if (data.size() == 30)
if (data.size() == 30 || data.size() == 31)
{
ret.m_type = Direct;
// Direct ICAP
@ -100,10 +111,8 @@ std::string ICAP::encoded() const
{
if (m_type == Direct)
{
if (!!m_direct[0])
BOOST_THROW_EXCEPTION(InvalidICAP());
std::string d = toBase36<Address::size>(m_direct);
while (d.size() < 30)
while (d.size() < 30) // always 34, sometimes 35.
d = "0" + d;
return iban("XE", d);
}

5
libethcore/ICAP.h

@ -36,7 +36,7 @@ namespace dev
namespace eth
{
struct InvalidICAP: virtual public dev::Exception {};
DEV_SIMPLE_EXCEPTION(InvalidICAP);
/**
* @brief Encapsulation of an ICAP address.
@ -62,6 +62,9 @@ public:
Indirect
};
/// Create a direct address for ICAP.
static Secret createDirect();
/// @returns IBAN encoding of client and data.
static std::string iban(std::string _c, std::string _d);
/// @returns Client and data from given IBAN address.

101
libethcore/KeyManager.cpp

@ -27,6 +27,7 @@
#include <libdevcore/Log.h>
#include <libdevcore/Guards.h>
#include <libdevcore/RLP.h>
#include <libdevcore/SHA3.h>
using namespace std;
using namespace dev;
using namespace eth;
@ -58,7 +59,7 @@ bool KeyManager::recode(Address const& _address, string const& _newPass, string
if (!store().recode(u, _newPass, [&](){ return getPassword(u, _pass); }, _kdf))
return false;
m_keyInfo[u].passHash = hashPassword(_newPass);
m_keyInfo[_address].passHash = hashPassword(_newPass);
write();
return true;
}
@ -95,10 +96,21 @@ bool KeyManager::load(string const& _pass)
{
h128 uuid(i[1]);
Address addr(i[0]);
if (m_store.contains(uuid))
if (uuid)
{
m_addrLookup[addr] = uuid;
m_keyInfo[uuid] = KeyInfo(h256(i[2]), string(i[3]));
if (m_store.contains(uuid))
{
m_addrLookup[addr] = uuid;
m_uuidLookup[uuid] = addr;
m_keyInfo[addr] = KeyInfo(h256(i[2]), string(i[3]), i.itemCount() > 4 ? string(i[4]) : "");
}
else
cwarn << "Missing key:" << uuid << addr;
}
else
{
// 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];
}
@ -124,10 +136,13 @@ bool KeyManager::load(string const& _pass)
Secret KeyManager::secret(Address const& _address, function<string()> const& _pass) const
{
auto it = m_addrLookup.find(_address);
if (it == m_addrLookup.end())
auto it = m_keyInfo.find(_address);
if (it == m_keyInfo.end())
return Secret();
return secret(it->second, _pass);
if (m_addrLookup.count(_address))
return secret(m_addrLookup.at(_address), _pass);
else
return brain(_pass());
}
Secret KeyManager::secret(h128 const& _uuid, function<string()> const& _pass) const
@ -137,10 +152,14 @@ Secret KeyManager::secret(h128 const& _uuid, function<string()> const& _pass) co
string KeyManager::getPassword(h128 const& _uuid, function<string()> const& _pass) const
{
auto kit = m_keyInfo.find(_uuid);
h256 ph;
if (kit != m_keyInfo.end())
ph = kit->second.passHash;
auto ait = m_uuidLookup.find(_uuid);
if (ait != m_uuidLookup.end())
{
auto kit = m_keyInfo.find(ait->second);
if (kit != m_keyInfo.end())
ph = kit->second.passHash;
}
return getPassword(ph, _pass);
}
@ -173,10 +192,10 @@ h128 KeyManager::uuid(Address const& _a) const
Address KeyManager::address(h128 const& _uuid) const
{
for (auto const& i: m_addrLookup)
if (i.second == _uuid)
return i.first;
return Address();
auto it = m_uuidLookup.find(_uuid);
if (it == m_uuidLookup.end())
return Address();
return it->second;
}
h128 KeyManager::import(Secret const& _s, string const& _accountName, string const& _pass, string const& _passwordHint)
@ -186,12 +205,34 @@ h128 KeyManager::import(Secret const& _s, string const& _accountName, string con
cachePassword(_pass);
m_passwordHint[passHash] = _passwordHint;
auto uuid = m_store.importSecret(_s.asBytesSec(), _pass);
m_keyInfo[uuid] = KeyInfo{passHash, _accountName};
m_keyInfo[addr] = KeyInfo{passHash, _accountName, ""};
m_addrLookup[addr] = uuid;
m_uuidLookup[uuid] = addr;
write(m_keysFile);
return uuid;
}
Secret KeyManager::brain(string const& _seed)
{
h256 r = sha3(_seed);
for (auto i = 0; i < 16384; ++i)
r = sha3(r);
Secret ret(r);
r.ref().cleanse();
while (toAddress(ret)[0])
ret = sha3(ret);
return ret;
}
Address KeyManager::importBrain(string const& _seed, string const& _accountName, string const& _passwordHint)
{
Address addr = toAddress(brain(_seed));
m_keyInfo[addr].accountName = _accountName;
m_keyInfo[addr].passwordHint = _passwordHint;
write();
return addr;
}
void KeyManager::importExisting(h128 const& _uuid, string const& _info, string const& _pass, string const& _passwordHint)
{
bytesSec key = m_store.secret(_uuid, [&](){ return _pass; });
@ -208,17 +249,19 @@ void KeyManager::importExisting(h128 const& _uuid, string const& _accountName, A
{
if (!m_passwordHint.count(_passHash))
m_passwordHint[_passHash] = _passwordHint;
m_uuidLookup[_uuid] = _address;
m_addrLookup[_address] = _uuid;
m_keyInfo[_uuid].passHash = _passHash;
m_keyInfo[_uuid].accountName = _accountName;
m_keyInfo[_address].passHash = _passHash;
m_keyInfo[_address].accountName = _accountName;
write(m_keysFile);
}
void KeyManager::kill(Address const& _a)
{
auto id = m_addrLookup[_a];
m_uuidLookup.erase(id);
m_addrLookup.erase(_a);
m_keyInfo.erase(id);
m_keyInfo.erase(_a);
m_store.kill(id);
write(m_keysFile);
}
@ -259,23 +302,22 @@ KeyPair KeyManager::presaleSecret(std::string const& _json, function<string(bool
Addresses KeyManager::accounts() const
{
Addresses ret;
ret.reserve(m_addrLookup.size());
for (auto const& i: m_addrLookup)
if (m_keyInfo.count(i.second) > 0)
ret.push_back(i.first);
ret.reserve(m_keyInfo.size());
for (auto const& i: m_keyInfo)
ret.push_back(i.first);
return ret;
}
bool KeyManager::hasAccount(const Address& _address) const
bool KeyManager::hasAccount(Address const& _address) const
{
return m_addrLookup.count(_address) && m_keyInfo.count(m_addrLookup.at(_address));
return m_keyInfo.count(_address);
}
string const& KeyManager::accountName(Address const& _address) const
{
try
{
return m_keyInfo.at(m_addrLookup.at(_address)).accountName;
return m_keyInfo.at(_address).accountName;
}
catch (...)
{
@ -287,7 +329,10 @@ string const& KeyManager::passwordHint(Address const& _address) const
{
try
{
return m_passwordHint.at(m_keyInfo.at(m_addrLookup.at(_address)).passHash);
auto& info = m_keyInfo.at(_address);
if (info.passwordHint.size())
return info.passwordHint;
return m_passwordHint.at(info.passHash);
}
catch (...)
{
@ -333,8 +378,8 @@ void KeyManager::write(SecureFixedHash<16> const& _key, string const& _keysFile)
for (auto const& address: accounts())
{
h128 id = uuid(address);
auto const& ki = m_keyInfo.at(id);
s.appendList(4) << address << id << ki.passHash << ki.accountName;
auto const& ki = m_keyInfo.at(address);
s.appendList(5) << address << id << ki.passHash << ki.accountName << ki.passwordHint;
}
s.appendList(m_passwordHint.size());
for (auto const& i: m_passwordHint)

17
libethcore/KeyManager.h

@ -36,12 +36,14 @@ class PasswordUnknown: public Exception {};
struct KeyInfo
{
KeyInfo() = default;
KeyInfo(h256 const& _passHash, std::string const& _accountName): passHash(_passHash), accountName(_accountName) {}
KeyInfo(h256 const& _passHash, std::string const& _accountName, std::string const& _passwordHint = std::string()): passHash(_passHash), accountName(_accountName), passwordHint(_passwordHint) {}
/// Hash of the password or h256() / UnknownPassword if unknown.
h256 passHash;
/// Name of the key, or JSON key info if begins with '{'.
std::string accountName;
/// Hint of the password. Alternative place for storage than the hash-based lookup.
std::string passwordHint;
};
static h256 const UnknownPassword;
@ -95,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.
@ -102,6 +107,7 @@ public:
h128 import(Secret const& _s, std::string const& _accountName, std::string const& _pass, std::string const& _passwordHint);
h128 import(Secret const& _s, std::string const& _accountName) { return import(_s, _accountName, defaultPassword(), std::string()); }
Address importBrain(std::string const& _seed, std::string const& _accountName, std::string const& _seedHint);
SecretStore& store() { return m_store; }
void importExisting(h128 const& _uuid, std::string const& _accountName, std::string const& _pass, std::string const& _passwordHint);
@ -126,6 +132,9 @@ public:
/// Extracts the secret key from the presale wallet.
KeyPair presaleSecret(std::string const& _json, std::function<std::string(bool)> const& _password);
/// @returns the brainwallet secret for the given seed.
static Secret brain(std::string const& _seed);
private:
std::string getPassword(h128 const& _uuid, std::function<std::string()> const& _pass = DontKnowThrow) const;
std::string getPassword(h256 const& _passHash, std::function<std::string()> const& _pass = DontKnowThrow) const;
@ -144,10 +153,12 @@ private:
// Ethereum keys.
/// Mapping key uuid -> address.
std::unordered_map<h128, Address> m_uuidLookup;
/// Mapping address -> key uuid.
std::unordered_map<Address, h128> m_addrLookup;
/// Mapping key uuid -> key info.
std::unordered_map<h128, KeyInfo> m_keyInfo;
/// Mapping address -> key info.
std::unordered_map<Address, KeyInfo> m_keyInfo;
/// Mapping password hash -> password hint.
std::unordered_map<h256, std::string> m_passwordHint;

2
libethereum/Executive.cpp

@ -383,7 +383,7 @@ bool Executive::go(OnOpFunc const& _onOp)
}
catch (VMException const& _e)
{
cnote/*clog(StateSafeExceptions)*/ << "Safe VM Exception. " << diagnostic_information(_e);
clog(StateSafeExceptions) << "Safe VM Exception. " << diagnostic_information(_e);
m_gas = 0;
m_excepted = toTransactionException(_e);
m_ext->revert();

6
libjsconsole/JSConsole.h

@ -41,7 +41,7 @@ public:
JSConsole(): m_engine(Engine()), m_printer(Printer(m_engine)) {}
~JSConsole() {}
void readExpression() const
bool readExpression() const
{
std::string cmd = "";
g_logPost = [](std::string const& a, char const*)
@ -83,6 +83,9 @@ public:
}
} while (openBrackets > 0);
if (cmd == "quit")
return false;
if (!isEmpty)
{
#if ETH_READLINE
@ -92,6 +95,7 @@ public:
std::string result = m_printer.prettyPrint(value).cstr();
std::cout << result << std::endl;
}
return true;
}
void eval(std::string const& _expression) { m_engine.eval(_expression.c_str()); }

6
libp2p/Common.h

@ -78,9 +78,9 @@ struct InvalidPublicIPAddress: virtual dev::Exception {};
struct InvalidHostIPAddress: virtual dev::Exception {};
struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; };
struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 1; };
struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 2; };
struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 3; };
struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 2; };
struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 3; };
struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 4; };
struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; };
struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; };
struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; };

1
libweb3jsonrpc/JsonHelper.cpp

@ -27,6 +27,7 @@
#include <libethereum/Client.h>
#include <libwebthree/WebThree.h>
#include <libethcore/CommonJS.h>
#include <libethcore/ICAP.h>
#include <libwhisper/Message.h>
#include <libwhisper/WhisperHost.h>
using namespace std;

6
libweb3jsonrpc/JsonHelper.h

@ -69,6 +69,12 @@ TransactionSkeleton toTransactionSkeleton(Json::Value const& _json);
LogFilter toLogFilter(Json::Value const& _json);
LogFilter toLogFilter(Json::Value const& _json, Interface const& _client); // commented to avoid warning. Uncomment once in use @ PoC-7.
class AddressResolver
{
public:
static Address fromJS(std::string const& _address);
};
template <class BlockInfoSub>
Json::Value toJson(BlockHeaderPolished<BlockInfoSub> const& _bh)
{

3
libweb3jsonrpc/WebThreeStubServer.cpp

@ -28,6 +28,7 @@
#include <libdevcore/FileSystem.h>
#include <libdevcore/CommonJS.h>
#include <libethcore/KeyManager.h>
#include <libethcore/ICAP.h>
#include <libethereum/Executive.h>
#include <libethereum/Block.h>
#include <libwebthree/WebThree.h>
@ -189,7 +190,7 @@ Json::Value WebThreeStubServer::admin_eth_newAccount(Json::Value const& _info, s
if (!_info.isMember("name"))
throw jsonrpc::JsonRpcException("No member found: name");
string name = _info["name"].asString();
auto s = Secret::random();
auto s = ICAP::createDirect();
h128 uuid;
if (_info.isMember("password"))
{

21
new.sh

@ -0,0 +1,21 @@
#!/bin/bash
type="$1"
path="$2"
name="$3"
if ! [[ -n $type ]] || ! [[ -n $path ]] || ! [[ -n $name ]]; then
echo "Usage new.sh <type> <path> <name>"
echo "e.g. new.sh plugin alethzero MyPlugin"
exit
fi
cd templates
for i in $type.*; do
n="../$path/${i/$type/$name}"
cp "$i" "$n"
perl -i -p -e "s/\\\$NAME/$name/gc" "$n"
done

41
templates/dockplugin.cpp

@ -0,0 +1,41 @@
/*
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 $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
#include "ui_$NAME.h"
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME"),
m_ui(new Ui::$NAME)
{
dock(Qt::RightDockWidgetArea, "$NAME")->setWidget(new QWidget());
m_ui->setupUi(dock()->widget());
}
$NAME::~$NAME()
{
}

56
templates/dockplugin.h

@ -0,0 +1,56 @@
/*
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 $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include <QListWidget>
#include <QPlainTextEdit>
#include "MainFace.h"
namespace Ui
{
class $NAME;
}
namespace dev
{
namespace az
{
class $NAME: public QObject, public Plugin
{
Q_OBJECT
public:
AllAccounts(MainFace* _m);
~AllAccounts();
private:
void onAllChange() override {}
void readSettings(QSettings const&) override {}
void writeSettings(QSettings&) override {}
private:
Ui::$NAME* m_ui;
};
}
}

36
templates/dockplugin.ui

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>$NAME</class>
<widget class="QWidget" name="NAME">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<resources/>
<connections/>
</ui>

37
templates/plugin.cpp

@ -0,0 +1,37 @@
/*
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 $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME")
{
}
$NAME::~$NAME()
{
}

46
templates/plugin.h

@ -0,0 +1,46 @@
/*
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 $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include "MainFace.h"
namespace dev
{
namespace az
{
class $NAME: public QObject, public Plugin
{
Q_OBJECT
public:
$NAME(MainFace* _m);
~$NAME();
private:
void onAllChange() override {}
void readSettings(QSettings const&) override {}
void writeSettings(QSettings&) override {}
};
}
}
Loading…
Cancel
Save