diff --git a/src/psbt.h b/src/psbt.h --- a/src/psbt.h +++ b/src/psbt.h @@ -527,6 +527,9 @@ SignatureData *out_sigdata = nullptr, bool use_dummy = false); +/** Counts the unsigned inputs of a PSBT. */ +size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt); + /** * Updates a PSBTOutput with information from provider. * diff --git a/src/psbt.cpp b/src/psbt.cpp --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -160,6 +160,17 @@ return !input.final_script_sig.empty(); } +size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt) { + size_t count = 0; + for (const auto &input : psbt.inputs) { + if (!PSBTInputSigned(input)) { + count++; + } + } + + return count; +} + void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index) { const CTxOut &out = psbt.tx->vout.at(index); diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -61,6 +61,7 @@ forms/openuridialog.ui forms/optionsdialog.ui forms/overviewpage.ui + forms/psbtoperationsdialog.ui forms/receivecoinsdialog.ui forms/receiverequestdialog.ui forms/debugwindow.ui @@ -294,6 +295,7 @@ openuridialog.cpp overviewpage.cpp paymentserver.cpp + psbtoperationsdialog.cpp qrimagewidget.cpp receivecoinsdialog.cpp receiverequestdialog.cpp diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -360,7 +360,7 @@ verifyMessageAction->setStatusTip( tr("Verify messages to ensure they were signed with specified Bitcoin " "addresses")); - m_load_psbt_action = new QAction(tr("Load PSBT..."), this); + m_load_psbt_action = new QAction(tr("&Load PSBT from file..."), this); m_load_psbt_action->setStatusTip( tr("Load Partially Signed Bitcoin Transaction")); diff --git a/src/qt/forms/psbtoperationsdialog.ui b/src/qt/forms/psbtoperationsdialog.ui new file mode 100644 --- /dev/null +++ b/src/qt/forms/psbtoperationsdialog.ui @@ -0,0 +1,148 @@ + + + PSBTOperationsDialog + + + + 0 + 0 + 585 + 327 + + + + Dialog + + + + 12 + + + QLayout::SetDefaultConstraint + + + 12 + + + + + 5 + + + 0 + + + 0 + + + + + + 75 + true + + + + false + + + + + + + + + + + + + false + + + true + + + + + + + 5 + + + + + + 0 + 0 + + + + + 50 + false + + + + Sign Tx + + + true + + + false + + + false + + + + + + + Broadcast Tx + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Copy to Clipboard + + + + + + + Save... + + + + + + + Close + + + + + + + + + + + + diff --git a/src/qt/psbtoperationsdialog.h b/src/qt/psbtoperationsdialog.h new file mode 100644 --- /dev/null +++ b/src/qt/psbtoperationsdialog.h @@ -0,0 +1,50 @@ +// Copyright (c) 2011-2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_PSBTOPERATIONSDIALOG_H +#define BITCOIN_QT_PSBTOPERATIONSDIALOG_H + +#include + +#include +#include +#include + +namespace Ui { +class PSBTOperationsDialog; +} + +/** Dialog showing transaction details. */ +class PSBTOperationsDialog : public QDialog { + Q_OBJECT + +public: + explicit PSBTOperationsDialog(QWidget *parent, WalletModel *walletModel, + ClientModel *clientModel); + ~PSBTOperationsDialog(); + + void openWithPSBT(PartiallySignedTransaction psbtx); + +public Q_SLOTS: + void signTransaction(); + void broadcastTransaction(); + void copyToClipboard(); + void saveTransaction(); + +private: + Ui::PSBTOperationsDialog *m_ui; + PartiallySignedTransaction m_transaction_data; + WalletModel *m_wallet_model; + ClientModel *m_client_model; + + enum class StatusLevel { INFO, WARN, ERR }; + + size_t couldSignInputs(const PartiallySignedTransaction &psbtx); + void updateTransactionDisplay(); + std::string renderTransaction(const PartiallySignedTransaction &psbtx); + void showStatus(const QString &msg, StatusLevel level); + void showTransactionStatus(const PartiallySignedTransaction &psbtx); +}; + +#endif // BITCOIN_QT_PSBTOPERATIONSDIALOG_H diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp new file mode 100644 --- /dev/null +++ b/src/qt/psbtoperationsdialog.cpp @@ -0,0 +1,316 @@ +// Copyright (c) 2011-2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include // For GetConfig +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include