Bitcoin Core  22.99.0
P2P Digital Currency
sendcoinsdialog.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 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 ClientModel;
16 class PlatformStyle;
17 class SendCoinsEntry;
18 class SendCoinsRecipient;
19 enum class SynchronizationState;
20 namespace wallet {
21 class CCoinControl;
22 } // namespace wallet
23 
24 namespace Ui {
25  class SendCoinsDialog;
26 }
27 
28 QT_BEGIN_NAMESPACE
29 class QUrl;
30 QT_END_NAMESPACE
31 
33 class SendCoinsDialog : public QDialog
34 {
35  Q_OBJECT
36 
37 public:
38  explicit SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = nullptr);
40 
42  void setModel(WalletModel *model);
43 
46  QWidget *setupTabChain(QWidget *prev);
47 
48  void setAddress(const QString &address);
49  void pasteEntry(const SendCoinsRecipient &rv);
50  bool handlePaymentRequest(const SendCoinsRecipient &recipient);
51 
52 public Q_SLOTS:
53  void clear();
54  void reject() override;
55  void accept() override;
57  void updateTabsAndLabels();
58  void setBalance(const interfaces::WalletBalances& balances);
59 
60 Q_SIGNALS:
61  void coinsSent(const uint256& txid);
62 
63 private:
64  Ui::SendCoinsDialog *ui;
67  std::unique_ptr<wallet::CCoinControl> m_coin_control;
68  std::unique_ptr<WalletModelTransaction> m_current_transaction;
72 
73  // Process WalletModel::SendCoinsReturn and generate a pair consisting
74  // of a message and message flags for use in Q_EMIT message().
75  // Additional parameter msgArg can be used via .arg(msgArg).
76  void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString());
77  void minimizeFeeSection(bool fMinimize);
78  // Format confirmation message
79  bool PrepareSendText(QString& question_string, QString& informative_text, QString& detailed_text);
82 
83 private Q_SLOTS:
84  void sendButtonClicked(bool checked);
87  void removeEntry(SendCoinsEntry* entry);
89  void updateDisplayUnit();
90  void coinControlFeatureChanged(bool);
92  void coinControlChangeChecked(int);
93  void coinControlChangeEdited(const QString &);
103  void updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state);
104  void updateSmartFeeLabel();
105 
106 Q_SIGNALS:
107  // Fired when a message should be reported to the user
108  void message(const QString &title, const QString &message, unsigned int style);
109 };
110 
111 
112 #define SEND_CONFIRM_DELAY 3
113 
114 class SendConfirmationDialog : public QMessageBox
115 {
116  Q_OBJECT
117 
118 public:
119  SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text = "", const QString& detailed_text = "", int secDelay = SEND_CONFIRM_DELAY, bool enable_send = true, bool always_show_unsigned = true, QWidget* parent = nullptr);
120  int exec() override;
121 
122 private Q_SLOTS:
123  void countDown();
124  void updateButtons();
125 
126 private:
127  QAbstractButton *yesButton;
128  QAbstractButton *m_psbt_button;
130  int secDelay;
131  QString confirmButtonText{tr("Send")};
133  QString m_psbt_button_text{tr("Create Unsigned")};
134 };
135 
136 #endif // BITCOIN_QT_SENDCOINSDIALOG_H
SendCoinsDialog::coinControlClipboardAmount
void coinControlClipboardAmount()
Definition: sendcoinsdialog.cpp:878
SendCoinsDialog::on_buttonChooseFee_clicked
void on_buttonChooseFee_clicked()
Definition: sendcoinsdialog.cpp:762
SendConfirmationDialog::m_psbt_button_text
QString m_psbt_button_text
Definition: sendcoinsdialog.h:133
SendCoinsDialog::fNewRecipientAllowed
bool fNewRecipientAllowed
Definition: sendcoinsdialog.h:69
count
static int count
Definition: tests.c:31
SendConfirmationDialog
Definition: sendcoinsdialog.h:114
SendConfirmationDialog::m_psbt_button
QAbstractButton * m_psbt_button
Definition: sendcoinsdialog.h:128
SendCoinsDialog::coinsSent
void coinsSent(const uint256 &txid)
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:52
SEND_CONFIRM_DELAY
#define SEND_CONFIRM_DELAY
Definition: sendcoinsdialog.h:112
walletmodel.h
SendCoinsDialog::updateNumberOfBlocks
void updateNumberOfBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state)
Definition: sendcoinsdialog.cpp:834
SendCoinsDialog::coinControlFeatureChanged
void coinControlFeatureChanged(bool)
Definition: sendcoinsdialog.cpp:914
SendCoinsDialog::coinControlButtonClicked
void coinControlButtonClicked()
Definition: sendcoinsdialog.cpp:926
SendCoinsDialog::updateCoinControlState
void updateCoinControlState()
Definition: sendcoinsdialog.cpp:819
wallet
Definition: node.h:38
SendCoinsDialog::addEntry
SendCoinsEntry * addEntry()
Definition: sendcoinsdialog.cpp:575
SendCoinsDialog::useAvailableBalance
void useAvailableBalance(SendCoinsEntry *entry)
Definition: sendcoinsdialog.cpp:773
SendCoinsDialog::~SendCoinsDialog
~SendCoinsDialog()
Definition: sendcoinsdialog.cpp:238
SendConfirmationDialog::m_enable_send
bool m_enable_send
Definition: sendcoinsdialog.h:132
SendCoinsDialog::clientModel
ClientModel * clientModel
Definition: sendcoinsdialog.h:65
SendCoinsDialog::updateDisplayUnit
void updateDisplayUnit()
Definition: sendcoinsdialog.cpp:700
SendCoinsDialog::sendButtonClicked
void sendButtonClicked(bool checked)
Definition: sendcoinsdialog.cpp:401
SendCoinsDialog::coinControlClipboardAfterFee
void coinControlClipboardAfterFee()
Definition: sendcoinsdialog.cpp:890
SendCoinsRecipient
Definition: sendcoinsrecipient.h:19
SendCoinsDialog::updateFeeMinimizedLabel
void updateFeeMinimizedLabel()
Definition: sendcoinsdialog.cpp:807
interfaces::WalletBalances
Collection of wallet balances.
Definition: wallet.h:365
SendConfirmationDialog::confirmButtonText
QString confirmButtonText
Definition: sendcoinsdialog.h:131
SendCoinsDialog::handlePaymentRequest
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
Definition: sendcoinsdialog.cpp:677
SendCoinsDialog::m_current_transaction
std::unique_ptr< WalletModelTransaction > m_current_transaction
Definition: sendcoinsdialog.h:68
SendCoinsDialog
Dialog for sending bitcoins.
Definition: sendcoinsdialog.h:33
SendConfirmationDialog::secDelay
int secDelay
Definition: sendcoinsdialog.h:130
SendCoinsDialog::minimizeFeeSection
void minimizeFeeSection(bool fMinimize)
Definition: sendcoinsdialog.cpp:752
SendCoinsDialog::setBalance
void setBalance(const interfaces::WalletBalances &balances)
Definition: sendcoinsdialog.cpp:685
SendCoinsDialog::setAddress
void setAddress(const QString &address)
Definition: sendcoinsdialog.cpp:633
SendCoinsDialog::setupTabChain
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
Definition: sendcoinsdialog.cpp:617
uint256
256-bit opaque blob.
Definition: uint256.h:124
SendCoinsDialog::m_coin_control
std::unique_ptr< wallet::CCoinControl > m_coin_control
Definition: sendcoinsdialog.h:67
SendCoinsDialog::platformStyle
const PlatformStyle * platformStyle
Definition: sendcoinsdialog.h:71
SendCoinsDialog::PrepareSendText
bool PrepareSendText(QString &question_string, QString &informative_text, QString &detailed_text)
Definition: sendcoinsdialog.cpp:249
SendCoinsDialog::coinControlClipboardBytes
void coinControlClipboardBytes()
Definition: sendcoinsdialog.cpp:896
SendCoinsDialog::ui
Ui::SendCoinsDialog * ui
Definition: sendcoinsdialog.h:64
SendCoinsDialog::updateTabsAndLabels
void updateTabsAndLabels()
Definition: sendcoinsdialog.cpp:598
SendCoinsDialog::coinControlClipboardChange
void coinControlClipboardChange()
Definition: sendcoinsdialog.cpp:908
SendConfirmationDialog::updateButtons
void updateButtons()
Definition: sendcoinsdialog.cpp:1082
ClientModel
Model for Bitcoin network client.
Definition: clientmodel.h:47
Ui
Definition: addressbookpage.h:14
SendConfirmationDialog::SendConfirmationDialog
SendConfirmationDialog(const QString &title, const QString &text, const QString &informative_text="", const QString &detailed_text="", int secDelay=SEND_CONFIRM_DELAY, bool enable_send=true, bool always_show_unsigned=true, QWidget *parent=nullptr)
Definition: sendcoinsdialog.cpp:1044
SendConfirmationDialog::countDown
void countDown()
Definition: sendcoinsdialog.cpp:1071
SendCoinsDialog::pasteEntry
void pasteEntry(const SendCoinsRecipient &rv)
Definition: sendcoinsdialog.cpp:653
SendConfirmationDialog::exec
int exec() override
Definition: sendcoinsdialog.cpp:1064
SendCoinsDialog::model
WalletModel * model
Definition: sendcoinsdialog.h:66
SendCoinsDialog::SendCoinsDialog
SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
Definition: sendcoinsdialog.cpp:61
SendCoinsDialog::setClientModel
void setClientModel(ClientModel *clientModel)
Definition: sendcoinsdialog.cpp:140
SendCoinsDialog::coinControlClipboardLowOutput
void coinControlClipboardLowOutput()
Definition: sendcoinsdialog.cpp:902
SendCoinsDialog::setModel
void setModel(WalletModel *model)
Definition: sendcoinsdialog.cpp:149
SendConfirmationDialog::yesButton
QAbstractButton * yesButton
Definition: sendcoinsdialog.h:127
SendCoinsDialog::coinControlChangeChecked
void coinControlChangeChecked(int)
Definition: sendcoinsdialog.cpp:934
WalletModel::SendCoinsReturn
Definition: walletmodel.h:91
SendCoinsDialog::message
void message(const QString &title, const QString &message, unsigned int style)
SendCoinsDialog::updateFeeSectionControls
void updateFeeSectionControls()
Definition: sendcoinsdialog.cpp:795
SendCoinsDialog::coinControlClipboardFee
void coinControlClipboardFee()
Definition: sendcoinsdialog.cpp:884
SendCoinsDialog::coinControlChangeEdited
void coinControlChangeEdited(const QString &)
Definition: sendcoinsdialog.cpp:949
SendCoinsEntry
A single entry in the dialog for sending bitcoins.
Definition: sendcoinsentry.h:28
SendCoinsDialog::coinControlUpdateLabels
void coinControlUpdateLabels()
Definition: sendcoinsdialog.cpp:1003
SendCoinsDialog::removeEntry
void removeEntry(SendCoinsEntry *entry)
Definition: sendcoinsdialog.cpp:604
SendCoinsDialog::fFeeMinimized
bool fFeeMinimized
Definition: sendcoinsdialog.h:70
SynchronizationState
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:105
SendCoinsDialog::clear
void clear()
Definition: sendcoinsdialog.cpp:545
SendCoinsDialog::accept
void accept() override
Definition: sendcoinsdialog.cpp:570
PlatformStyle
Definition: platformstyle.h:13
SendCoinsDialog::processSendCoinsReturn
void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg=QString())
Definition: sendcoinsdialog.cpp:707
SendCoinsDialog::updateSmartFeeLabel
void updateSmartFeeLabel()
Definition: sendcoinsdialog.cpp:840
SendCoinsDialog::coinControlClipboardQuantity
void coinControlClipboardQuantity()
Definition: sendcoinsdialog.cpp:872
SendCoinsDialog::on_buttonMinimizeFee_clicked
void on_buttonMinimizeFee_clicked()
Definition: sendcoinsdialog.cpp:767
SendConfirmationDialog::countDownTimer
QTimer countDownTimer
Definition: sendcoinsdialog.h:129
SendCoinsDialog::reject
void reject() override
Definition: sendcoinsdialog.cpp:565