1 // Copyright (c) 2011-2019 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_SENDCOINSDIALOG_H 6 #define BITCOIN_QT_SENDCOINSDIALOG_H 7 8 #include <qt/walletmodel.h> 9 10 #include <QDialog> 11 #include <QMessageBox> 12 #include <QString> 13 #include <QTimer> 14 15 class CCoinControl; 16 class ClientModel; 17 class PlatformStyle; 18 class SendCoinsEntry; 19 class SendCoinsRecipient; 20 enum class SynchronizationState; 21 22 namespace Ui { 23 class SendCoinsDialog; 24 } 25 26 QT_BEGIN_NAMESPACE 27 class QUrl; 28 QT_END_NAMESPACE 29 30 /** Dialog for sending bitcoins */ 31 class SendCoinsDialog : public QDialog 32 { 33 Q_OBJECT 34 35 public: 36 explicit SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = nullptr); 37 ~SendCoinsDialog(); 38 39 void setClientModel(ClientModel *clientModel); 40 void setModel(WalletModel *model); 41 42 /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). 43 */ 44 QWidget *setupTabChain(QWidget *prev); 45 46 void setAddress(const QString &address); 47 void pasteEntry(const SendCoinsRecipient &rv); 48 bool handlePaymentRequest(const SendCoinsRecipient &recipient); 49 50 public Q_SLOTS: 51 void clear(); 52 void reject() override; 53 void accept() override; 54 SendCoinsEntry *addEntry(); 55 void updateTabsAndLabels(); 56 void setBalance(const interfaces::WalletBalances& balances); 57 58 Q_SIGNALS: 59 void coinsSent(const uint256& txid); 60 61 private: 62 Ui::SendCoinsDialog *ui; 63 ClientModel *clientModel; 64 WalletModel *model; 65 std::unique_ptr<CCoinControl> m_coin_control; 66 std::unique_ptr<WalletModelTransaction> m_current_transaction; 67 bool fNewRecipientAllowed; 68 bool fFeeMinimized; 69 const PlatformStyle *platformStyle; 70 71 // Process WalletModel::SendCoinsReturn and generate a pair consisting 72 // of a message and message flags for use in Q_EMIT message(). 73 // Additional parameter msgArg can be used via .arg(msgArg). 74 void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString()); 75 void minimizeFeeSection(bool fMinimize); 76 // Format confirmation message 77 bool PrepareSendText(QString& question_string, QString& informative_text, QString& detailed_text); 78 void updateFeeMinimizedLabel(); 79 // Update the passed in CCoinControl with state from the GUI 80 void updateCoinControlState(CCoinControl& ctrl); 81 82 private Q_SLOTS: 83 void on_sendButton_clicked(); 84 void on_buttonChooseFee_clicked(); 85 void on_buttonMinimizeFee_clicked(); 86 void removeEntry(SendCoinsEntry* entry); 87 void useAvailableBalance(SendCoinsEntry* entry); 88 void updateDisplayUnit(); 89 void coinControlFeatureChanged(bool); 90 void coinControlButtonClicked(); 91 void coinControlChangeChecked(int); 92 void coinControlChangeEdited(const QString &); 93 void coinControlUpdateLabels(); 94 void coinControlClipboardQuantity(); 95 void coinControlClipboardAmount(); 96 void coinControlClipboardFee(); 97 void coinControlClipboardAfterFee(); 98 void coinControlClipboardBytes(); 99 void coinControlClipboardLowOutput(); 100 void coinControlClipboardChange(); 101 void updateFeeSectionControls(); 102 void updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state); 103 void updateSmartFeeLabel(); 104 105 Q_SIGNALS: 106 // Fired when a message should be reported to the user 107 void message(const QString &title, const QString &message, unsigned int style); 108 }; 109 110 111 #define SEND_CONFIRM_DELAY 3 112 113 class SendConfirmationDialog : public QMessageBox 114 { 115 Q_OBJECT 116 117 public: 118 SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text = "", const QString& detailed_text = "", int secDelay = SEND_CONFIRM_DELAY, const QString& confirmText = "Send", QWidget* parent = nullptr); 119 int exec() override; 120 121 private Q_SLOTS: 122 void countDown(); 123 void updateYesButton(); 124 125 private: 126 QAbstractButton *yesButton; 127 QTimer countDownTimer; 128 int secDelay; 129 QString confirmButtonText; 130 }; 131 132 #endif // BITCOIN_QT_SENDCOINSDIALOG_H 133