Bitcoin Core  24.99.0
P2P Digital Currency
sendcoinsdialog.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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/clientmodel.h>
9 #include <qt/walletmodel.h>
10 
11 #include <QDialog>
12 #include <QMessageBox>
13 #include <QString>
14 #include <QTimer>
15 
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;
66  WalletModel* model{nullptr};
67  std::unique_ptr<wallet::CCoinControl> m_coin_control;
68  std::unique_ptr<WalletModelTransaction> m_current_transaction;
70  bool fFeeMinimized{true};
72 
73  // Copy PSBT to clipboard and offer to save it.
75  // Process WalletModel::SendCoinsReturn and generate a pair consisting
76  // of a message and message flags for use in Q_EMIT message().
77  // Additional parameter msgArg can be used via .arg(msgArg).
78  void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString());
79  void minimizeFeeSection(bool fMinimize);
80  // Format confirmation message
81  bool PrepareSendText(QString& question_string, QString& informative_text, QString& detailed_text);
82  /* Sign PSBT using external signer.
83  *
84  * @param[in,out] psbtx the PSBT to sign
85  * @param[in,out] mtx needed to attempt to finalize
86  * @param[in,out] complete whether the PSBT is complete (a successfully signed multisig transaction may not be complete)
87  *
88  * @returns false if any failure occurred, which may include the user rejection of a transaction on the device.
89  */
93 
94 private Q_SLOTS:
95  void sendButtonClicked(bool checked);
98  void removeEntry(SendCoinsEntry* entry);
100  void refreshBalance();
101  void coinControlFeatureChanged(bool);
103  void coinControlChangeChecked(int);
104  void coinControlChangeEdited(const QString &);
114  void updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state);
115  void updateSmartFeeLabel();
116 
117 Q_SIGNALS:
118  // Fired when a message should be reported to the user
119  void message(const QString &title, const QString &message, unsigned int style);
120 };
121 
122 
123 #define SEND_CONFIRM_DELAY 3
124 
125 class SendConfirmationDialog : public QMessageBox
126 {
127  Q_OBJECT
128 
129 public:
130  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);
131  /* Returns QMessageBox::Cancel, QMessageBox::Yes when "Send" is
132  clicked and QMessageBox::Save when "Create Unsigned" is clicked. */
133  int exec() override;
134 
135 private Q_SLOTS:
136  void countDown();
137  void updateButtons();
138 
139 private:
140  QAbstractButton *yesButton;
141  QAbstractButton *m_psbt_button;
143  int secDelay;
144  QString confirmButtonText{tr("Send")};
146  QString m_psbt_button_text{tr("Create Unsigned")};
147 };
148 
149 #endif // BITCOIN_QT_SENDCOINSDIALOG_H
Model for Bitcoin network client.
Definition: clientmodel.h:54
Dialog for sending bitcoins.
void useAvailableBalance(SendCoinsEntry *entry)
WalletModel * model
void presentPSBT(PartiallySignedTransaction &psbt)
ClientModel * clientModel
void coinControlChangeEdited(const QString &)
void coinControlChangeChecked(int)
void coinControlClipboardFee()
Ui::SendCoinsDialog * ui
void on_buttonChooseFee_clicked()
void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg=QString())
void setClientModel(ClientModel *clientModel)
void updateFeeSectionControls()
SendCoinsEntry * addEntry()
void updateNumberOfBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state)
void pasteEntry(const SendCoinsRecipient &rv)
void updateFeeMinimizedLabel()
void accept() override
const PlatformStyle * platformStyle
std::unique_ptr< wallet::CCoinControl > m_coin_control
void coinControlClipboardQuantity()
void coinControlButtonClicked()
void coinControlClipboardAfterFee()
bool signWithExternalSigner(PartiallySignedTransaction &psbt, CMutableTransaction &mtx, bool &complete)
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
bool PrepareSendText(QString &question_string, QString &informative_text, QString &detailed_text)
void sendButtonClicked(bool checked)
void setModel(WalletModel *model)
void coinControlClipboardLowOutput()
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
void setBalance(const interfaces::WalletBalances &balances)
void coinControlClipboardAmount()
void setAddress(const QString &address)
void coinControlClipboardChange()
std::unique_ptr< WalletModelTransaction > m_current_transaction
void removeEntry(SendCoinsEntry *entry)
void reject() override
void coinControlClipboardBytes()
void message(const QString &title, const QString &message, unsigned int style)
SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
void coinsSent(const uint256 &txid)
void on_buttonMinimizeFee_clicked()
void coinControlFeatureChanged(bool)
void minimizeFeeSection(bool fMinimize)
A single entry in the dialog for sending bitcoins.
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)
QAbstractButton * m_psbt_button
QAbstractButton * yesButton
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:53
256-bit opaque blob.
Definition: uint256.h:105
SyncType
Definition: clientmodel.h:39
Definition: node.h:39
#define SEND_CONFIRM_DELAY
A mutable version of CTransaction.
Definition: transaction.h:380
A version of CTransaction with the PSBT format.
Definition: psbt.h:947
Collection of wallet balances.
Definition: wallet.h:366
static int count
Definition: tests.c:34
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:84