|
18 | 18 | #include <QMessageBox>
|
19 | 19 | #include <QPushButton>
|
20 | 20 |
|
21 |
| -AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) : |
| 21 | +AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureString* passphrase_out) : |
22 | 22 | QDialog(parent),
|
23 | 23 | ui(new Ui::AskPassphraseDialog),
|
24 | 24 | mode(_mode),
|
25 | 25 | model(nullptr),
|
26 |
| - fCapsLock(false) |
| 26 | + fCapsLock(false), |
| 27 | + m_passphrase_out(passphrase_out) |
27 | 28 | {
|
28 | 29 | ui->setupUi(this);
|
29 | 30 |
|
@@ -90,7 +91,7 @@ void AskPassphraseDialog::setModel(WalletModel *_model)
|
90 | 91 | void AskPassphraseDialog::accept()
|
91 | 92 | {
|
92 | 93 | SecureString oldpass, newpass1, newpass2;
|
93 |
| - if(!model) |
| 94 | + if (!model && mode != Encrypt) |
94 | 95 | return;
|
95 | 96 | oldpass.reserve(MAX_PASSPHRASE_SIZE);
|
96 | 97 | newpass1.reserve(MAX_PASSPHRASE_SIZE);
|
@@ -119,24 +120,33 @@ void AskPassphraseDialog::accept()
|
119 | 120 | {
|
120 | 121 | if(newpass1 == newpass2)
|
121 | 122 | {
|
122 |
| - if(model->setWalletEncrypted(true, newpass1)) |
123 |
| - { |
124 |
| - QMessageBox::warning(this, tr("Wallet encrypted"), |
| 123 | + QString encryption_reminder = tr("Remember that encrypting your wallet cannot fully protect " |
| 124 | + "your bitcoins from being stolen by malware infecting your computer."); |
| 125 | + if (m_passphrase_out) { |
| 126 | + m_passphrase_out->assign(newpass1); |
| 127 | + QMessageBox::warning(this, tr("Wallet to be encrypted"), |
125 | 128 | "<qt>" +
|
126 |
| - tr("Your wallet is now encrypted. " |
127 |
| - "Remember that encrypting your wallet cannot fully protect " |
128 |
| - "your bitcoins from being stolen by malware infecting your computer.") + |
129 |
| - "<br><br><b>" + |
130 |
| - tr("IMPORTANT: Any previous backups you have made of your wallet file " |
131 |
| - "should be replaced with the newly generated, encrypted wallet file. " |
132 |
| - "For security reasons, previous backups of the unencrypted wallet file " |
133 |
| - "will become useless as soon as you start using the new, encrypted wallet.") + |
| 129 | + tr("Your wallet is about to be encrypted. ") + encryption_reminder + |
134 | 130 | "</b></qt>");
|
135 |
| - } |
136 |
| - else |
137 |
| - { |
138 |
| - QMessageBox::critical(this, tr("Wallet encryption failed"), |
139 |
| - tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); |
| 131 | + } else { |
| 132 | + assert(model != nullptr); |
| 133 | + if(model->setWalletEncrypted(true, newpass1)) |
| 134 | + { |
| 135 | + QMessageBox::warning(this, tr("Wallet encrypted"), |
| 136 | + "<qt>" + |
| 137 | + tr("Your wallet is now encrypted. ") + encryption_reminder + |
| 138 | + "<br><br><b>" + |
| 139 | + tr("IMPORTANT: Any previous backups you have made of your wallet file " |
| 140 | + "should be replaced with the newly generated, encrypted wallet file. " |
| 141 | + "For security reasons, previous backups of the unencrypted wallet file " |
| 142 | + "will become useless as soon as you start using the new, encrypted wallet.") + |
| 143 | + "</b></qt>"); |
| 144 | + } |
| 145 | + else |
| 146 | + { |
| 147 | + QMessageBox::critical(this, tr("Wallet encryption failed"), |
| 148 | + tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); |
| 149 | + } |
140 | 150 | }
|
141 | 151 | QDialog::accept(); // Success
|
142 | 152 | }
|
|
0 commit comments