diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 4ec917bca..26d91d2cb 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -150,8 +151,8 @@ Main::Main(QWidget *parent) : m_qwebConnector = new QWebThreeConnector(); m_server = unique_ptr(new WebThreeStubServer(m_qwebConnector, *web3(), keysAsVector(m_myKeys))); + m_server->setIdentities(keysAsVector(owned())); m_server->StartListening(); - connect(ui->webView, &QWebView::loadStarted, [this]() { @@ -164,6 +165,7 @@ Main::Main(QWidget *parent) : QWebFrame* f = ui->webView->page()->mainFrame(); f->disconnect(SIGNAL(javaScriptWindowObjectCleared())); connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qweb)); + connect(m_qweb, SIGNAL(onNewId(QString)), this, SLOT(addNewId(QString))); }); connect(ui->webView, &QWebView::loadFinished, [=]() @@ -201,6 +203,14 @@ Main::~Main() writeSettings(); } +void Main::addNewId(QString _ids) +{ + Secret _id = jsToSecret(_ids.toStdString()); + KeyPair kp(_id); + m_myIdentities.push_back(kp); + m_server->setIdentities(keysAsVector(owned())); +} + dev::p2p::NetworkPreferences Main::netPrefs() const { return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked()); diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index f54fc5717..890607e5a 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -154,6 +154,7 @@ private slots: void on_newIdentity_triggered(); void refreshWhisper(); + void addNewId(QString _ids); signals: void poll(); diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 5218c6ff5..a342a3b1a 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -167,6 +167,8 @@ void QWebThree::onDataProcessed(QString _json, QString _addInfo) m_watches.push_back(f["result"].toInt()); if (!_addInfo.compare("shhNewFilter") && f.contains("result")) m_shhWatches.push_back(f["result"].toInt()); + if (!_addInfo.compare("newIdentity") && f.contains("result")) + emit onNewId(f["result"].toString()); response(formatOutput(f)); } diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index ad5de71b7..25160cf1e 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -47,6 +47,7 @@ public slots: signals: void processData(QString _json, QString _addInfo); void response(QString _json); + void onNewId(QString _id); private: std::vector m_watches; diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 332276850..74deb87c7 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -463,7 +463,6 @@ std::string WebThreeStubServer::newGroup(std::string const& _id, std::string con std::string WebThreeStubServer::newIdentity() { KeyPair kp = KeyPair::create(); - // emit newId return toJS(kp.pub()); }