mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[gui] PSBT Operations Dialog (sign & broadcast)
Add a "PSBT Operations" dialog, reached from the "Load PSBT..." menu item, giving options to sign or broadcast the loaded PSBT as appropriate, as well as copying the result to the clipboard or saving it to a file.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <qt/askpassphrasedialog.h>
|
||||
#include <qt/clientmodel.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/psbtoperationsdialog.h>
|
||||
#include <qt/optionsmodel.h>
|
||||
#include <qt/overviewpage.h>
|
||||
#include <qt/platformstyle.h>
|
||||
@@ -224,58 +225,10 @@ void WalletView::gotoLoadPSBT()
|
||||
return;
|
||||
}
|
||||
|
||||
CMutableTransaction mtx;
|
||||
bool complete = false;
|
||||
PSBTAnalysis analysis = AnalyzePSBT(psbtx);
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("PSBT");
|
||||
switch (analysis.next) {
|
||||
case PSBTRole::CREATOR:
|
||||
case PSBTRole::UPDATER:
|
||||
msgBox.setInformativeText("PSBT is incomplete. Copy to clipboard for manual inspection?");
|
||||
break;
|
||||
case PSBTRole::SIGNER:
|
||||
msgBox.setInformativeText("Transaction needs more signatures. Copy to clipboard?");
|
||||
break;
|
||||
case PSBTRole::FINALIZER:
|
||||
case PSBTRole::EXTRACTOR:
|
||||
complete = FinalizeAndExtractPSBT(psbtx, mtx);
|
||||
if (complete) {
|
||||
msgBox.setInformativeText(tr("Would you like to send this transaction?"));
|
||||
} else {
|
||||
// The analyzer missed something, e.g. if there are final_scriptSig/final_scriptWitness
|
||||
// but with invalid signatures.
|
||||
msgBox.setInformativeText(tr("There was an unexpected problem processing the PSBT. Copy to clipboard for manual inspection?"));
|
||||
}
|
||||
}
|
||||
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||
switch (msgBox.exec()) {
|
||||
case QMessageBox::Yes: {
|
||||
if (complete) {
|
||||
std::string err_string;
|
||||
CTransactionRef tx = MakeTransactionRef(mtx);
|
||||
|
||||
TransactionError result = BroadcastTransaction(*clientModel->node().context(), tx, err_string, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), /* relay */ true, /* wait_callback */ false);
|
||||
if (result == TransactionError::OK) {
|
||||
Q_EMIT message(tr("Success"), tr("Broadcasted transaction successfully."), CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL);
|
||||
} else {
|
||||
Q_EMIT message(tr("Error"), QString::fromStdString(err_string), CClientUIInterface::MSG_ERROR);
|
||||
}
|
||||
} else {
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << psbtx;
|
||||
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
||||
Q_EMIT message(tr("PSBT copied"), "Copied to clipboard", CClientUIInterface::MSG_INFORMATION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case QMessageBox::Cancel:
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
PSBTOperationsDialog* dlg = new PSBTOperationsDialog(this, walletModel, clientModel);
|
||||
dlg->openWithPSBT(psbtx);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
bool WalletView::handlePaymentRequest(const SendCoinsRecipient& recipient)
|
||||
|
||||
Reference in New Issue
Block a user