Bitcoin Core  31.0.0
P2P Digital Currency
sendcoinsdialog.h
Go to the documentation of this file.
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_SENDCOINSDIALOG_H
6 #define BITCOIN_QT_SENDCOINSDIALOG_H
7 
9 #include <qt/clientmodel.h>
10 #include <qt/walletmodel.h>
11 
12 #include <QDialog>
13 #include <QMessageBox>
14 #include <QString>
15 #include <QTimer>
16 
17 class PlatformStyle;
18 class SendCoinsEntry;
19 class SendCoinsRecipient;
20 enum class SynchronizationState;
21 namespace wallet {
22 class CCoinControl;
23 } // namespace wallet
24 
25 namespace Ui {
26  class SendCoinsDialog;
27 }
28 
29 QT_BEGIN_NAMESPACE
30 class QUrl;
31 QT_END_NAMESPACE
32 
34 class SendCoinsDialog : public QDialog
35 {
36  Q_OBJECT
37 
38 public:
39  explicit SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = nullptr);
41 
43  void setModel(WalletModel *model);
44 
47  QWidget *setupTabChain(QWidget *prev);
48 
49  void setAddress(const QString &address);
50  void pasteEntry(const SendCoinsRecipient &rv);
51  bool handlePaymentRequest(const SendCoinsRecipient &recipient);
52 
53  // Only used for testing-purposes
55 
56 public Q_SLOTS:
57  void clear();
58  void reject() override;
59  void accept() override;
61  void updateTabsAndLabels();
62  void setBalance(const interfaces::WalletBalances& balances);
63 
64 Q_SIGNALS:
65  void coinsSent(const Txid& txid);
66 
67 private:
68  Ui::SendCoinsDialog *ui;
70  WalletModel* model{nullptr};
71  std::unique_ptr<wallet::CCoinControl> m_coin_control;
72  std::unique_ptr<WalletModelTransaction> m_current_transaction;
74  bool fFeeMinimized{true};
76 
77  // Copy PSBT to clipboard and offer to save it.
79  // Process WalletModel::SendCoinsReturn and generate a pair consisting
80  // of a message and message flags for use in Q_EMIT message().
81  // Additional parameter msgArg can be used via .arg(msgArg).
82  void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString());
83  void minimizeFeeSection(bool fMinimize);
84  // Format confirmation message
85  bool PrepareSendText(QString& question_string, QString& informative_text, QString& detailed_text);
86  /* Sign PSBT using external signer.
87  *
88  * @param[in,out] psbtx the PSBT to sign
89  * @param[in,out] mtx needed to attempt to finalize
90  * @param[in,out] complete whether the PSBT is complete (a successfully signed multisig transaction may not be complete)
91  *
92  * @returns false if any failure occurred, which may include the user rejection of a transaction on the device.
93  */
97 
98 private Q_SLOTS:
99  void sendButtonClicked(bool checked);
102  void removeEntry(SendCoinsEntry* entry);
103  void useAvailableBalance(SendCoinsEntry* entry);
104  void refreshBalance();
105  void coinControlFeatureChanged(bool);
107 #if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
108  void coinControlChangeChecked(Qt::CheckState);
109 #else
110  void coinControlChangeChecked(int);
111 #endif
112  void coinControlChangeEdited(const QString &);
121  void updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state);
122  void updateSmartFeeLabel();
123 
124 Q_SIGNALS:
125  // Fired when a message should be reported to the user
126  void message(const QString &title, const QString &message, unsigned int style);
127 };
128 
129 
130 #define SEND_CONFIRM_DELAY 3
131 
132 class SendConfirmationDialog : public QMessageBox
133 {
134  Q_OBJECT
135 
136 public:
137  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);
138  /* Returns QMessageBox::Cancel, QMessageBox::Yes when "Send" is
139  clicked and QMessageBox::Save when "Create Unsigned" is clicked. */
140  int exec() override;
141 
142 private Q_SLOTS:
143  void countDown();
144  void updateButtons();
145 
146 private:
147  QAbstractButton *yesButton;
148  QAbstractButton *m_psbt_button;
150  int secDelay;
151  QString confirmButtonText{tr("Send")};
153  QString m_psbt_button_text{tr("Create Unsigned")};
154 };
155 
156 #endif // BITCOIN_QT_SENDCOINSDIALOG_H
bool signWithExternalSigner(PartiallySignedTransaction &psbt, CMutableTransaction &mtx, bool &complete)
void removeEntry(SendCoinsEntry *entry)
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:93
void presentPSBT(PartiallySignedTransaction &psbt)
void sendButtonClicked(bool checked)
void updateFeeMinimizedLabel()
void on_buttonChooseFee_clicked()
void reject() override
wallet::CCoinControl * getCoinControl()
void coinControlClipboardQuantity()
void coinControlClipboardAfterFee()
#define SEND_CONFIRM_DELAY
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
A version of CTransaction with the PSBT format.
Definition: psbt.h:1138
A single entry in the dialog for sending bitcoins.
void coinControlFeatureChanged(bool)
std::unique_ptr< wallet::CCoinControl > m_coin_control
std::unique_ptr< WalletModelTransaction > m_current_transaction
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
Ui::SendCoinsDialog * ui
SendCoinsEntry * addEntry()
void setBalance(const interfaces::WalletBalances &balances)
void setAddress(const QString &address)
void coinControlClipboardChange()
Collection of wallet balances.
Definition: wallet.h:367
void useAvailableBalance(SendCoinsEntry *entry)
void setClientModel(ClientModel *clientModel)
ClientModel * clientModel
void coinsSent(const Txid &txid)
WalletModel * model
Dialog for sending bitcoins.
void coinControlChangeEdited(const QString &)
Model for Bitcoin network client.
Definition: clientmodel.h:56
void setModel(WalletModel *model)
SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
void accept() override
void coinControlChangeChecked(Qt::CheckState)
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)
SyncType
Definition: clientmodel.h:42
void minimizeFeeSection(bool fMinimize)
void updateFeeSectionControls()
bool PrepareSendText(QString &question_string, QString &informative_text, QString &detailed_text)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:48
void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg=QString())
static int count
void coinControlClipboardBytes()
A mutable version of CTransaction.
Definition: transaction.h:357
const PlatformStyle * platformStyle
void coinControlClipboardAmount()
void on_buttonMinimizeFee_clicked()
void pasteEntry(const SendCoinsRecipient &rv)
QAbstractButton * yesButton
void message(const QString &title, const QString &message, unsigned int style)
QAbstractButton * m_psbt_button
Coin Control Features.
Definition: coincontrol.h:83
void coinControlButtonClicked()
void coinControlClipboardFee()
void updateNumberOfBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state)