diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index 7fa72bae2..4f8231b38 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -69,6 +69,21 @@
Tab 1
+
+ 0
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
-
@@ -81,6 +96,9 @@
+ -
+
+
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index 02e0c56de..e7a4a1415 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -186,7 +186,7 @@ Main::Main(QWidget *parent) :
else if (pocnumber == 4)
m_servers.push_back("54.72.31.55:30303");
else if (pocnumber == 5)
- m_servers.push_back("54.201.28.117:30303");
+ m_servers.push_back("54.72.31.55:30305");
else
{
connect(&m_webCtrl, &QNetworkAccessManager::finished, [&](QNetworkReply* _r)
@@ -226,10 +226,8 @@ Main::Main(QWidget *parent) :
QWebFrame* f = ui->webView->page()->currentFrame();
connect(f, &QWebFrame::javaScriptWindowObjectCleared, [=](){
- f->addToJavaScriptWindowObject("eth", new QEthereum(this, m_client.get(), owned()), QWebFrame::ScriptOwnership);
- f->addToJavaScriptWindowObject("u256", new U256Helper, QWebFrame::ScriptOwnership);
- f->addToJavaScriptWindowObject("key", new KeyHelper, QWebFrame::ScriptOwnership);
- f->addToJavaScriptWindowObject("bytes", new BytesHelper, QWebFrame::ScriptOwnership);
+ auto qe = new QEthereum(this, m_client.get(), owned());
+ qe->setup(f);
});
readSettings();
@@ -251,6 +249,12 @@ Main::~Main()
writeSettings();
}
+void Main::on_jsInput_returnPressed()
+{
+ ui->jsInput->setText(ui->webView->page()->currentFrame()->evaluateJavaScript(ui->jsInput->text()).toString());
+ ui->jsInput->setSelection(0, ui->jsInput->text().size());
+}
+
QString Main::pretty(eth::Address _a) const
{
h256 n;
@@ -368,10 +372,10 @@ void Main::readSettings()
ui->port->setValue(s.value("port", ui->port->value()).toInt());
ui->nameReg->setText(s.value("NameReg", "").toString());
ui->urlEdit->setText(s.value("url", "http://gavwood.com/gavcoin.html").toString());
- on_urlEdit_editingFinished();
+ on_urlEdit_returnPressed();
}
-void Main::on_urlEdit_editingFinished()
+void Main::on_urlEdit_returnPressed()
{
ui->webView->setUrl(ui->urlEdit->text());
}
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index b61390416..bf8ddf58a 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -69,10 +69,11 @@ private slots:
void on_nameReg_textChanged();
void on_preview_triggered() { refresh(true); }
void on_quit_triggered() { close(); }
- void on_urlEdit_editingFinished();
+ void on_urlEdit_returnPressed();
void on_debugStep_triggered();
void on_debug_clicked();
void on_debugTimeline_valueChanged();
+ void on_jsInput_returnPressed();
void refresh(bool _override = false);
void refreshNetwork();
diff --git a/libethcore/Common.h b/libethcore/Common.h
index c99246868..67fa36adc 100644
--- a/libethcore/Common.h
+++ b/libethcore/Common.h
@@ -24,7 +24,7 @@
#pragma once
// define version
-#define ETH_VERSION 0.5.1
+#define ETH_VERSION 0.5.2
// way to many uint to size_t warnings in 32 bit build
#ifdef _M_IX86
diff --git a/libethereum/BlockInfo.cpp b/libethereum/BlockInfo.cpp
index f2f62fc48..dd6ab53ff 100644
--- a/libethereum/BlockInfo.cpp
+++ b/libethereum/BlockInfo.cpp
@@ -142,7 +142,7 @@ void BlockInfo::verifyInternals(bytesConstRef _block) const
{
RLP root(_block);
- u256 mgp = 0;
+ u256 mgp = (u256)-1;
Overlay db;
GenericTrieDB t(&db);
@@ -153,15 +153,14 @@ void BlockInfo::verifyInternals(bytesConstRef _block) const
bytes k = rlp(i);
t.insert(&k, tr.data());
u256 gp = tr[0][1].toInt();
- if (!i || mgp > gp)
- mgp = gp;
+ mgp = min(mgp, gp);
++i;
}
if (transactionsRoot != t.root())
throw InvalidTransactionsHash(t.root(), transactionsRoot);
if (minGasPrice > mgp)
- throw InvalidMinGasPrice();
+ throw InvalidMinGasPrice(minGasPrice, mgp);
if (sha3Uncles != sha3(root[2].data()))
throw InvalidUnclesHash();
diff --git a/libethereum/Exceptions.h b/libethereum/Exceptions.h
index 0517602a1..f3c17dde6 100644
--- a/libethereum/Exceptions.h
+++ b/libethereum/Exceptions.h
@@ -35,7 +35,7 @@ class InvalidTransactionsHash: public Exception { public: InvalidTransactionsHas
class InvalidTransaction: public Exception {};
class InvalidDifficulty: public Exception {};
class InvalidGasLimit: public Exception {};
-class InvalidMinGasPrice: public Exception {};
+class InvalidMinGasPrice: public Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual std::string description() const { return "Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"; } };
class InvalidTransactionGasUsed: public Exception {};
class InvalidTransactionStateRoot: public Exception {};
class InvalidTimestamp: public Exception {};
diff --git a/libethereum/Transaction.cpp b/libethereum/Transaction.cpp
index 828d85846..61e8247d5 100644
--- a/libethereum/Transaction.cpp
+++ b/libethereum/Transaction.cpp
@@ -123,6 +123,8 @@ void Transaction::fillStream(RLPStream& _s, bool _sig) const
h256 Transaction::kFromMessage(h256 _msg, h256 _priv)
{
// TODO!
+// bytes v(32, 1);
+// bytes k(32, 0);
/*
v = '\x01' * 32
k = '\x00' * 32
diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp
index 71ea08ad4..47138cdbc 100644
--- a/libqethereum/QEthereum.cpp
+++ b/libqethereum/QEthereum.cpp
@@ -1,5 +1,6 @@
#include
#include
+#include
#include
#include
#include
@@ -192,6 +193,22 @@ QEthereum::~QEthereum()
{
}
+void QEthereum::setup(QWebFrame* _e)
+{
+ // disconnect
+ disconnect(SIGNAL(changed()));
+ _e->addToJavaScriptWindowObject("eth", this, QWebFrame::ScriptOwnership);
+ _e->addToJavaScriptWindowObject("u256", new U256Helper, QWebFrame::ScriptOwnership);
+ _e->addToJavaScriptWindowObject("key", new KeyHelper, QWebFrame::ScriptOwnership);
+ _e->addToJavaScriptWindowObject("bytes", new BytesHelper, QWebFrame::ScriptOwnership);
+// _e->evaluateJavaScript("xeth = new Object({\"callback\": function(f) { eth.testcallback.connect(f) }})");
+ _e->evaluateJavaScript("eth.onChanged = function(f) { eth.changed.connect(f) }");
+}
+
+void QEthereum::teardown(QWebFrame* _e)
+{
+}
+
Client* QEthereum::client() const
{
return m_client;
diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h
index 23dc0c248..ce51592b0 100644
--- a/libqethereum/QEthereum.h
+++ b/libqethereum/QEthereum.h
@@ -1,6 +1,7 @@
#pragma once
#include
+#include
#include
#include
@@ -11,6 +12,7 @@ class State;
class QQmlEngine;
class QJSEngine;
+class QWebFrame;
class QEthereum;
class QmlAccount;
@@ -291,6 +293,9 @@ public:
eth::Client* client() const;
+ void setup(QWebFrame* _e);
+ void teardown(QWebFrame* _e);
+
Q_INVOKABLE QVariant/*eth::Address*/ coinbase() const;
Q_INVOKABLE bool isListening() const;
@@ -304,6 +309,7 @@ public:
Q_INVOKABLE QVariant gasPrice() const { return toQJS(10 * eth::szabo); }
Q_INVOKABLE QString ethTest() const { return "Hello world!"; }
+ Q_INVOKABLE void ethTest2() { changed(); }
Q_INVOKABLE QVariant/*eth::KeyPair*/ key() const;
Q_INVOKABLE QList keys() const;
@@ -329,6 +335,7 @@ public slots:
signals:
void changed();
+ void testcallback();
// void netChanged();
// void miningChanged();