askpassphrasedialog.h
1 // Copyright (c) 2011-present The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 5 #ifndef BITCOIN_QT_ASKPASSPHRASEDIALOG_H 6 #define BITCOIN_QT_ASKPASSPHRASEDIALOG_H 7 8 #include <QDialog> 9 10 #include <support/allocators/secure.h> 11 12 class WalletModel; 13 14 namespace Ui { 15 class AskPassphraseDialog; 16 } 17 18 /** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. 19 */ 20 class AskPassphraseDialog : public QDialog 21 { 22 Q_OBJECT 23 24 public: 25 enum Mode { 26 Encrypt, /**< Ask passphrase twice and encrypt */ 27 Unlock, /**< Ask passphrase and unlock */ 28 ChangePass, /**< Ask old passphrase + new passphrase twice */ 29 UnlockMigration, /**< Ask passphrase for unlocking during migration */ 30 }; 31 32 explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr); 33 ~AskPassphraseDialog(); 34 35 void accept() override; 36 37 void setModel(WalletModel *model); 38 39 private: 40 Ui::AskPassphraseDialog *ui; 41 Mode mode; 42 WalletModel* model{nullptr}; 43 bool fCapsLock{false}; 44 SecureString* m_passphrase_out; 45 46 private Q_SLOTS: 47 void textChanged(); 48 void secureClearPassFields(); 49 void toggleShowPassword(bool); 50 51 protected: 52 bool event(QEvent *event) override; 53 bool eventFilter(QObject *object, QEvent *event) override; 54 }; 55 56 #endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H