Browse Source

Import/export keys.

cl-refactor
Gav Wood 11 years ago
parent
commit
8833a27474
  1. 15
      alethzero/Main.ui
  2. 29
      alethzero/MainWin.cpp
  3. 2
      alethzero/MainWin.h

15
alethzero/Main.ui

@ -135,8 +135,11 @@
<string>T&amp;ools</string>
</property>
<addaction name="mine"/>
<addaction name="create"/>
<addaction name="preview"/>
<addaction name="separator"/>
<addaction name="create"/>
<addaction name="importKey"/>
<addaction name="exportKey"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
@ -1032,6 +1035,16 @@
<string>&amp;Kill Blockchain</string>
</property>
</action>
<action name="importKey">
<property name="text">
<string>&amp;Import Key...</string>
</property>
</action>
<action name="exportKey">
<property name="text">
<string>&amp;Export Selected Key...</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

29
alethzero/MainWin.cpp

@ -385,6 +385,35 @@ void Main::readSettings()
on_urlEdit_returnPressed();
}
void Main::on_importKey_triggered()
{
QString s = QInputDialog::getText(this, "Import Account Key", "Enter account's secret key");
bytes b = fromHex(s.toStdString());
if (b.size() == 32)
{
auto k = KeyPair(h256(b));
if (std::find(m_myKeys.begin(), m_myKeys.end(), k) == m_myKeys.end())
{
m_myKeys.append(k);
m_keysChanged = true;
update();
}
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).");
}
void Main::on_exportKey_triggered()
{
if (ui->ourAccounts->currentRow() >= 0 && ui->ourAccounts->currentRow() < m_myKeys.size())
{
auto k = m_myKeys[ui->ourAccounts->currentRow()];
QMessageBox::information(this, "Export Account Key", "Secret key to account " + render(k.address()) + " is:\n" + QString::fromStdString(toHex(k.sec().ref())));
}
}
void Main::on_urlEdit_returnPressed()
{
ui->webView->setUrl(ui->urlEdit->text());

2
alethzero/MainWin.h

@ -77,6 +77,8 @@ private slots:
void on_debugTimeline_valueChanged();
void on_jsInput_returnPressed();
void on_killBlockchain_triggered();
void on_importKey_triggered();
void on_exportKey_triggered();
void refresh(bool _override = false);
void refreshNetwork();

Loading…
Cancel
Save