Browse Source

HD wallet stuff.

cl-refactor
Gav Wood 9 years ago
parent
commit
be9f868eb0
  1. 9
      alethzero/Main.ui
  2. 27
      alethzero/MainWin.cpp
  3. 3
      alethzero/MainWin.h
  4. 4
      ethkey/KeyAux.h
  5. 4
      libethcore/Common.cpp
  6. 10
      libethcore/KeyManager.cpp
  7. 3
      libethcore/KeyManager.h

9
alethzero/Main.ui

@ -211,6 +211,7 @@
<property name="title">
<string>&amp;Debug</string>
</property>
<addaction name="debugPending"/>
<addaction name="debugCurrent"/>
<addaction name="debugDumpState"/>
<addaction name="debugDumpStatePre"/>
@ -1385,6 +1386,14 @@ font-size: 14pt</string>
<string>&amp;Bulk Inject Transactions...</string>
</property>
</action>
<action name="debugPending">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Debug &amp;Pending Transaction</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

27
alethzero/MainWin.cpp

@ -240,7 +240,7 @@ Main::Main(QWidget* _parent):
ui->vmSmart->setEnabled(false);
#endif
readSettings();
readSettings(true, false);
m_transact = new Transact(this, this);
m_transact->setWindowFlags(Qt::Dialog);
@ -262,6 +262,8 @@ Main::Main(QWidget* _parent):
for (auto const& i: *s_linkedPlugins)
initPlugin(i(this));
readSettings(false, true);
}
Main::~Main()
@ -850,13 +852,15 @@ Secret Main::retrieveSecret(Address const& _address) const
}
}
void Main::readSettings(bool _skipGeometry)
void Main::readSettings(bool _skipGeometry, bool _onlyGeometry)
{
QSettings s("ethereum", "alethzero");
if (!_skipGeometry)
restoreGeometry(s.value("geometry").toByteArray());
restoreState(s.value("windowState").toByteArray());
if (_onlyGeometry)
return;
forEach([&](std::shared_ptr<Plugin> p)
{
@ -1543,6 +1547,7 @@ void Main::on_transactionQueue_currentItemChanged()
int i = ui->transactionQueue->currentRow();
if (i >= 0 && i < (int)ethereum()->pending().size())
{
ui->debugPending->setEnabled(true);
Transaction tx(ethereum()->pending()[i]);
TransactionReceipt receipt(ethereum()->postState().receipt(i));
auto ss = tx.safeSender();
@ -1582,6 +1587,8 @@ void Main::on_transactionQueue_currentItemChanged()
// s << "Pre: " << fs.rootHash() << "<br/>";
// s << "Post: <b>" << ts.rootHash() << "</b>";
}
else
ui->debugPending->setEnabled(false);
ui->pendingInfo->setHtml(QString::fromStdString(s.str()));
ui->pendingInfo->moveCursor(QTextCursor::Start);
@ -1779,6 +1786,22 @@ void Main::on_debugCurrent_triggered()
}
}
void Main::on_debugPending_triggered()
{
int txi = ui->transactionQueue->currentRow();
if (txi == -1)
return;
Block b = ethereum()->postState();
bytes t = b.pending()[txi].rlp();
State s(ethereum()->state(txi));
BlockInfo bi(b.info());
Executive e(s, ethereum()->blockChain(), EnvInfo(bi));
Debugger dw(this, this);
dw.populate(e, Transaction(t, CheckTransaction::Everything));
dw.exec();
}
std::string minHex(h256 const& _h)
{
unsigned i = 0;

3
alethzero/MainWin.h

@ -191,6 +191,7 @@ private slots:
// Debugger
void on_debugCurrent_triggered();
void on_debugPending_triggered();
void on_debugDumpState_triggered() { debugDumpState(1); }
void on_debugDumpStatePre_triggered() { debugDumpState(0); }
void on_dumpBlockState_triggered();
@ -223,7 +224,7 @@ private:
Address getCurrencies() const;
void updateFee();
void readSettings(bool _skipGeometry = false);
void readSettings(bool _skipGeometry = false, bool _onlyGeometry = false);
void writeSettings();
void setPrivateChain(QString const& _private, bool _forceConfigure = false);

4
ethkey/KeyAux.h

@ -289,6 +289,8 @@ public:
{
if (h128 u = fromUUID(_signKey))
return Secret(secretStore().secret(u, [&](){ return getPassword("Enter password for key: "); }));
if (_signKey.substr(0, 6) == "brain#" && _signKey.find(":") != string::npos)
return KeyManager::subkey(KeyManager::brain(_signKey.substr(_signKey.find(":"))), stoul(_signKey.substr(6, _signKey.find(":" - 7))));
if (_signKey.substr(0, 6) == "brain:")
return KeyManager::brain(_signKey.substr(6));
if (_signKey == "brain")
@ -644,7 +646,7 @@ public:
<< endl
<< "Transaction operating modes:" << endl
<< " -d,--decode-tx [<hex>|<file>] Decode given transaction." << endl
<< " -s,--sign-tx [ <address>|<uuid>|<file>|brain(:<brain-phrase>) ] [ <hex>|<file> , ... ] (Re-)Sign given transaction." << endl
<< " -s,--sign-tx [ <address>|<uuid>|<file>|brain((#<HD-index>):<brain-phrase>) ] [ <hex>|<file> , ... ] (Re-)Sign given transaction." << endl
<< endl
<< "Encryption configuration:" << endl
<< " --kdf <kdfname> Specify KDF to use when encrypting (default: sc rypt)" << endl

4
libethcore/Common.cpp

@ -112,14 +112,14 @@ std::string formatBalance(bigint const& _b)
else
b = (u256)_b;
if (b > units()[0].first * 10000)
if (b > units()[0].first * 1000)
{
ret << (b / units()[0].first) << " " << units()[0].second;
return ret.str();
}
ret << setprecision(5);
for (auto const& i: units())
if (i.first != 1 && b >= i.first * 100)
if (i.first != 1 && b >= i.first * 1)
{
ret << (double(b / (i.first / 1000)) / 1000.0) << " " << i.second;
return ret.str();

10
libethcore/KeyManager.cpp

@ -224,6 +224,16 @@ Secret KeyManager::brain(string const& _seed)
return ret;
}
Secret KeyManager::subkey(Secret const& _s, unsigned _index)
{
RLPStream out(2);
out << _s.ref();
out << _index;
bytesSec r;
out.swapOut(r.writable());
return sha3(r);
}
Address KeyManager::importBrain(string const& _seed, string const& _accountName, string const& _passwordHint)
{
Address addr = toAddress(brain(_seed));

3
libethcore/KeyManager.h

@ -135,6 +135,9 @@ public:
/// @returns the brainwallet secret for the given seed.
static Secret brain(std::string const& _seed);
/// @returns the HD subkey for a given key.
static Secret subkey(Secret const& _s, unsigned _index);
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;

Loading…
Cancel
Save