|
|
|
@ -401,6 +401,52 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
|
|
|
|
|
{
|
|
|
|
|
// Serialize the PSBT
|
|
|
|
|
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
|
ssTx << psbtx;
|
|
|
|
|
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setText("Unsigned Transaction");
|
|
|
|
|
msgBox.setInformativeText("The PSBT has been copied to the clipboard. You can also save it.");
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Discard);
|
|
|
|
|
switch (msgBox.exec()) {
|
|
|
|
|
case QMessageBox::Save: {
|
|
|
|
|
QString selectedFilter;
|
|
|
|
|
QString fileNameSuggestion = "";
|
|
|
|
|
bool first = true;
|
|
|
|
|
for (const SendCoinsRecipient &rcp : m_current_transaction->getRecipients()) {
|
|
|
|
|
if (!first) {
|
|
|
|
|
fileNameSuggestion.append(" - ");
|
|
|
|
|
}
|
|
|
|
|
QString labelOrAddress = rcp.label.isEmpty() ? rcp.address : rcp.label;
|
|
|
|
|
QString amount = BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
|
|
|
|
|
fileNameSuggestion.append(labelOrAddress + "-" + amount);
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
fileNameSuggestion.append(".psbt");
|
|
|
|
|
QString filename = GUIUtil::getSaveFileName(this,
|
|
|
|
|
tr("Save Transaction Data"), fileNameSuggestion,
|
|
|
|
|
//: Expanded name of the binary PSBT file format. See: BIP 174.
|
|
|
|
|
tr("Partially Signed Transaction (Binary)") + QLatin1String(" (*.psbt)"), &selectedFilter);
|
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary};
|
|
|
|
|
out << ssTx.str();
|
|
|
|
|
out.close();
|
|
|
|
|
Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::Discard:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
} // msgBox.exec()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
|
|
|
|
|
{
|
|
|
|
|
if(!model || !model->getOptionsModel())
|
|
|
|
@ -481,48 +527,7 @@ void SendCoinsDialog::sendButtonClicked([[maybe_unused]] bool checked)
|
|
|
|
|
|
|
|
|
|
// Copy PSBT to clipboard and offer to save
|
|
|
|
|
assert(!complete);
|
|
|
|
|
// Serialize the PSBT
|
|
|
|
|
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
|
ssTx << psbtx;
|
|
|
|
|
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setText("Unsigned Transaction");
|
|
|
|
|
msgBox.setInformativeText("The PSBT has been copied to the clipboard. You can also save it.");
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Discard);
|
|
|
|
|
switch (msgBox.exec()) {
|
|
|
|
|
case QMessageBox::Save: {
|
|
|
|
|
QString selectedFilter;
|
|
|
|
|
QString fileNameSuggestion = "";
|
|
|
|
|
bool first = true;
|
|
|
|
|
for (const SendCoinsRecipient &rcp : m_current_transaction->getRecipients()) {
|
|
|
|
|
if (!first) {
|
|
|
|
|
fileNameSuggestion.append(" - ");
|
|
|
|
|
}
|
|
|
|
|
QString labelOrAddress = rcp.label.isEmpty() ? rcp.address : rcp.label;
|
|
|
|
|
QString amount = BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
|
|
|
|
|
fileNameSuggestion.append(labelOrAddress + "-" + amount);
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
fileNameSuggestion.append(".psbt");
|
|
|
|
|
QString filename = GUIUtil::getSaveFileName(this,
|
|
|
|
|
tr("Save Transaction Data"), fileNameSuggestion,
|
|
|
|
|
//: Expanded name of the binary PSBT file format. See: BIP 174.
|
|
|
|
|
tr("Partially Signed Transaction (Binary)") + QLatin1String(" (*.psbt)"), &selectedFilter);
|
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary};
|
|
|
|
|
out << ssTx.str();
|
|
|
|
|
out.close();
|
|
|
|
|
Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::Discard:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
} // msgBox.exec()
|
|
|
|
|
presentPSBT(psbtx);
|
|
|
|
|
} else {
|
|
|
|
|
assert(!model->wallet().privateKeysDisabled());
|
|
|
|
|
// now send the prepared transaction
|
|
|
|
|