Skip to content

Commit 82aabbd

Browse files
committed
Prompt for wordlist when creating a new keychain.
1 parent 4b51995 commit 82aabbd

4 files changed

+46
-3
lines changed

src/importbip39dialog.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222

2323
ImportBIP39Dialog::ImportBIP39Dialog(QWidget* parent)
2424
: QDialog(parent)
25+
{
26+
init();
27+
}
28+
29+
ImportBIP39Dialog::ImportBIP39Dialog(const QString& name, QWidget* parent)
30+
: QDialog(parent)
31+
{
32+
init(name);
33+
}
34+
35+
void ImportBIP39Dialog::init(const QString& name)
2536
{
2637
setWindowTitle(tr("Import Wordlist"));
2738

@@ -34,6 +45,13 @@ ImportBIP39Dialog::ImportBIP39Dialog(QWidget* parent)
3445

3546
QLabel* nameLabel = new QLabel(tr("Name:"));
3647
m_nameEdit = new QLineEdit();
48+
49+
if (!name.isEmpty())
50+
{
51+
m_nameEdit->setText(name);
52+
m_nameEdit->setReadOnly(true);
53+
}
54+
3755
QHBoxLayout* nameLayout = new QHBoxLayout();
3856
nameLayout->addWidget(nameLabel);
3957
nameLayout->addWidget(m_nameEdit);

src/importbip39dialog.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ class ImportBIP39Dialog : public QDialog
2222

2323
public:
2424
ImportBIP39Dialog(QWidget* parent = NULL);
25+
ImportBIP39Dialog(const QString& name, QWidget* parent = NULL);
2526

2627
QString getName() const;
2728
secure_bytes_t getSeed() const;
2829

2930
private:
31+
void init(const QString& name = QString());
32+
3033
QLineEdit* m_nameEdit;
3134
QLineEdit* m_wordlistEdit;
3235
};

src/mainwindow.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,32 @@ void MainWindow::newKeychain()
695695

696696
{
697697
// TODO: Randomize using user input for entropy
698+
secure_bytes_t seed = getRandomBytes(32);
699+
700+
// Prompt user to write down and verify word list
701+
ViewBIP39Dialog viewDlg(name, seed, this);
702+
viewDlg.exec();
703+
704+
while (true)
705+
{
706+
try
707+
{
708+
ImportBIP39Dialog checkDlg(name, this);
709+
if (!checkDlg.exec()) return; // User canceled out
710+
711+
secure_bytes_t seed2 = checkDlg.getSeed();
712+
if (seed == seed2) break;
713+
else throw std::runtime_error("Wordlists do not match.");
714+
}
715+
catch (const exception& e)
716+
{
717+
showError(e.what());
718+
}
719+
}
720+
698721
CoinDB::VaultLock lock(synchedVault);
699722
if (!synchedVault.isVaultOpen()) throw std::runtime_error("No vault is open.");
700-
secure_bytes_t entropy = getRandomBytes(32);
701-
synchedVault.getVault()->newKeychain(name.toStdString(), entropy);
723+
synchedVault.getVault()->newKeychain(name.toStdString(), seed);
702724
}
703725

704726
keychainModel->update();

src/versioninfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <openssl/opensslv.h>
1717

1818
// Definitions
19-
const QString VERSIONTEXT("0.9.2 beta");
19+
const QString VERSIONTEXT("0.9.3 beta");
2020

2121
const QString commitHash(COMMIT_HASH);
2222
const QString shortCommitHash(QString(COMMIT_HASH).left(7));

0 commit comments

Comments
 (0)