Browse Source

Merge branch 'develop' into poc-6+

cl-refactor
Gav Wood 10 years ago
parent
commit
ff2da7b8e2
  1. 33
      alethzero/MainWin.cpp
  2. 2
      libethereum/DownloadMan.cpp
  3. 4
      libethereum/EthereumPeer.cpp
  4. 2
      test/rlp.cpp

33
alethzero/MainWin.cpp

@ -28,6 +28,7 @@
#include <QtGui/QClipboard>
#include <QtCore/QtCore>
#include <boost/algorithm/string.hpp>
#include <test/JsonSpiritHeaders.h>
#include <libserpent/funcs.h>
#include <libserpent/util.h>
#include <libdevcrypto/FileSystem.h>
@ -49,6 +50,7 @@ using namespace std;
using namespace dev;
using namespace dev::p2p;
using namespace dev::eth;
namespace js = json_spirit;
static void initUnits(QComboBox* _b)
{
@ -573,10 +575,29 @@ void Main::on_importKey_triggered()
void Main::on_importKeyFile_triggered()
{
QString s = QFileDialog::getOpenFileName(this, "Import Account", QDir::homePath(), "JSON Files (*.json);;All Files (*)");
bytes b = fromHex(s.toStdString());
if (b.size() == 32)
try
{
auto k = KeyPair(h256(b));
js::mValue val;
json_spirit::read_string(asString(contents(s.toStdString())), val);
js::mObject obj = val.get_obj();
KeyPair k;
if (obj["encseed"].type() == js::str_type)
{
string encseedstr = obj["encseed"].get_str();
bytes encseed = fromHex(encseedstr);
Secret sec = sha3(encseed);
k = KeyPair(sec);
if (obj["ethaddr"].type() == js::str_type)
{
Address a(obj["ethaddr"].get_str());
Address b = k.address();
if (a != b && QMessageBox::warning(this, "Key File Invalid", "Could not import the secret key: it doesn't agree with the given address.\nWould you like to attempt to import anyway?", QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
}
}
else
throw 0;
if (std::find(m_myKeys.begin(), m_myKeys.end(), k) == m_myKeys.end())
{
m_myKeys.append(k);
@ -586,8 +607,10 @@ void Main::on_importKeyFile_triggered()
else
QMessageBox::warning(this, "Already Have Key", "Could not import the secret key: we already own this account.");
}
else
QMessageBox::warning(this, "Invalid Entry", "Could not import the secret key; invalid key entered. Make sure it is 64 hex characters (0-9 or A-F).");
catch (...)
{
QMessageBox::warning(this, "Key File Invalid", "Could not find secret key definition. This is probably not an Ethereum key file.");
}
}
void Main::on_exportKey_triggered()

2
libethereum/DownloadMan.cpp

@ -50,7 +50,7 @@ h256Set DownloadSub::nextFetch(unsigned _n)
m_indices.clear();
m_remaining.clear();
if (!m_man)
if (!m_man || m_man->chain().empty())
return h256Set();
m_asked = (~(m_man->taken() + m_attempted)).lowest(_n);

4
libethereum/EthereumPeer.cpp

@ -176,12 +176,12 @@ bool EthereumPeer::interpret(RLP const& _r)
unsigned limit = _r[2].toInt<unsigned>();
clogS(NetMessageSummary) << "GetBlockHashes (" << limit << "entries," << later.abridged() << ")";
unsigned c = min<unsigned>(max<unsigned>(1, host()->m_chain.number(later)) - 1, limit);
unsigned c = min<unsigned>(host()->m_chain.number(later), limit);
RLPStream s;
prep(s).appendList(1 + c).append(BlockHashesPacket);
h256 p = host()->m_chain.details(later).parent;
for (unsigned i = 0; i < c; ++i, p = host()->m_chain.details(p).parent)
for (unsigned i = 0; i < c && p; ++i, p = host()->m_chain.details(p).parent)
s << p;
sealAndSend(s);
break;

2
test/rlp.cpp

@ -22,12 +22,12 @@
#include <fstream>
#include <sstream>
#include "JsonSpiritHeaders.h"
#include <libdevcore/Log.h>
#include <libdevcore/RLP.h>
#include <libdevcore/Common.h>
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include "JsonSpiritHeaders.h"
using namespace std;
using namespace dev;

Loading…
Cancel
Save