From 15e9979cbc2e8419ad418ab3dc301bf68acc55e0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 15 Aug 2015 21:54:54 +0200 Subject: [PATCH] Presale import in AZ. --- alethzero/Main.ui | 6 ++++++ alethzero/MainWin.cpp | 22 ++++++++++++++++++++++ alethzero/MainWin.h | 1 + 3 files changed, 29 insertions(+) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index 32a806fea..a26fb8f2c 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -164,6 +164,7 @@ + @@ -1394,6 +1395,11 @@ font-size: 14pt Debug &Pending Transaction + + + Import Ether &Presale Wallet... + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 05c2667df..995553803 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1022,6 +1022,28 @@ void Main::on_claimPresale_triggered() } } +void Main::on_importPresale_triggered() +{ + QString s = QFileDialog::getOpenFileName(this, "Claim Account Contents", QDir::homePath(), "JSON Files (*.json);;All Files (*)"); + try + { + string pass; + KeyPair k = m_keyManager.presaleSecret(dev::contentsString(s.toStdString()), [&](bool){ return (pass = QInputDialog::getText(this, "Enter Password", "Enter the wallet's passphrase", QLineEdit::Password).toStdString()); }); + cnote << k.address(); + if (!m_keyManager.hasAccount(k.address())) + keyManager().import(k.secret(), "Presale wallet (" + s.toStdString() + ")", pass, "Same password as for the presale wallet"); + else + QMessageBox::warning(this, "Already Have Key", "Could not import the secret key: we already own this account."); + } + catch (dev::eth::PasswordUnknown&) {} + catch (...) + { + cerr << "Unhandled exception!" << endl << + boost::current_exception_diagnostic_information(); + 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() { if (ui->ourAccounts->currentRow() >= 0) diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index dd2e668b8..2bccbde57 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -157,6 +157,7 @@ private slots: void on_reencryptAll_triggered(); void on_importKeyFile_triggered(); void on_claimPresale_triggered(); + void on_importPresale_triggered(); void on_exportKey_triggered(); // Tools