mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-04 08:22:36 +02:00
Optionally allow AskPassphraseDialog to output the passphrase
This commit is contained in:
parent
bc6d8a3662
commit
60adb21c7a
@ -18,12 +18,13 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
|
AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureString* passphrase_out) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AskPassphraseDialog),
|
ui(new Ui::AskPassphraseDialog),
|
||||||
mode(_mode),
|
mode(_mode),
|
||||||
model(nullptr),
|
model(nullptr),
|
||||||
fCapsLock(false)
|
fCapsLock(false),
|
||||||
|
m_passphrase_out(passphrase_out)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ void AskPassphraseDialog::setModel(WalletModel *_model)
|
|||||||
void AskPassphraseDialog::accept()
|
void AskPassphraseDialog::accept()
|
||||||
{
|
{
|
||||||
SecureString oldpass, newpass1, newpass2;
|
SecureString oldpass, newpass1, newpass2;
|
||||||
if(!model)
|
if (!model && mode != Encrypt)
|
||||||
return;
|
return;
|
||||||
oldpass.reserve(MAX_PASSPHRASE_SIZE);
|
oldpass.reserve(MAX_PASSPHRASE_SIZE);
|
||||||
newpass1.reserve(MAX_PASSPHRASE_SIZE);
|
newpass1.reserve(MAX_PASSPHRASE_SIZE);
|
||||||
@ -119,24 +120,33 @@ void AskPassphraseDialog::accept()
|
|||||||
{
|
{
|
||||||
if(newpass1 == newpass2)
|
if(newpass1 == newpass2)
|
||||||
{
|
{
|
||||||
if(model->setWalletEncrypted(true, newpass1))
|
QString encryption_reminder = tr("Remember that encrypting your wallet cannot fully protect "
|
||||||
{
|
"your bitcoins from being stolen by malware infecting your computer.");
|
||||||
QMessageBox::warning(this, tr("Wallet encrypted"),
|
if (m_passphrase_out) {
|
||||||
|
m_passphrase_out->assign(newpass1);
|
||||||
|
QMessageBox::warning(this, tr("Wallet to be encrypted"),
|
||||||
"<qt>" +
|
"<qt>" +
|
||||||
tr("Your wallet is now encrypted. "
|
tr("Your wallet is about to be encrypted. ") + encryption_reminder +
|
||||||
"Remember that encrypting your wallet cannot fully protect "
|
|
||||||
"your bitcoins from being stolen by malware infecting your computer.") +
|
|
||||||
"<br><br><b>" +
|
|
||||||
tr("IMPORTANT: Any previous backups you have made of your wallet file "
|
|
||||||
"should be replaced with the newly generated, encrypted wallet file. "
|
|
||||||
"For security reasons, previous backups of the unencrypted wallet file "
|
|
||||||
"will become useless as soon as you start using the new, encrypted wallet.") +
|
|
||||||
"</b></qt>");
|
"</b></qt>");
|
||||||
}
|
} else {
|
||||||
else
|
assert(model != nullptr);
|
||||||
{
|
if(model->setWalletEncrypted(true, newpass1))
|
||||||
QMessageBox::critical(this, tr("Wallet encryption failed"),
|
{
|
||||||
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
|
QMessageBox::warning(this, tr("Wallet encrypted"),
|
||||||
|
"<qt>" +
|
||||||
|
tr("Your wallet is now encrypted. ") + encryption_reminder +
|
||||||
|
"<br><br><b>" +
|
||||||
|
tr("IMPORTANT: Any previous backups you have made of your wallet file "
|
||||||
|
"should be replaced with the newly generated, encrypted wallet file. "
|
||||||
|
"For security reasons, previous backups of the unencrypted wallet file "
|
||||||
|
"will become useless as soon as you start using the new, encrypted wallet.") +
|
||||||
|
"</b></qt>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Wallet encryption failed"),
|
||||||
|
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QDialog::accept(); // Success
|
QDialog::accept(); // Success
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include <support/allocators/secure.h>
|
||||||
|
|
||||||
class WalletModel;
|
class WalletModel;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -27,7 +29,7 @@ public:
|
|||||||
Decrypt /**< Ask passphrase and decrypt wallet */
|
Decrypt /**< Ask passphrase and decrypt wallet */
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit AskPassphraseDialog(Mode mode, QWidget *parent);
|
explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr);
|
||||||
~AskPassphraseDialog();
|
~AskPassphraseDialog();
|
||||||
|
|
||||||
void accept();
|
void accept();
|
||||||
@ -39,6 +41,7 @@ private:
|
|||||||
Mode mode;
|
Mode mode;
|
||||||
WalletModel *model;
|
WalletModel *model;
|
||||||
bool fCapsLock;
|
bool fCapsLock;
|
||||||
|
SecureString* m_passphrase_out;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
Loading…
Reference in New Issue
Block a user