mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
[gui] save PSBT to file
co-authored-by: Glenn Willen <gwillen@nerdnet.org>
This commit is contained in:
parent
1d05a9d80b
commit
f6895301f7
1 changed files with 42 additions and 3 deletions
|
@ -314,7 +314,7 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
|
|||
|
||||
question_string.append("<br /><span style='font-size:10pt;'>");
|
||||
if (model->wallet().privateKeysDisabled()) {
|
||||
question_string.append(tr("Please, review your transaction proposal. This will produce a Partially Signed Bitcoin Transaction (PSBT) which you can copy and then sign with e.g. an offline %1 wallet, or a PSBT-compatible hardware wallet.").arg(PACKAGE_NAME));
|
||||
question_string.append(tr("Please, review your transaction proposal. This will produce a Partially Signed Bitcoin Transaction (PSBT) which you can save or copy and then sign with e.g. an offline %1 wallet, or a PSBT-compatible hardware wallet.").arg(PACKAGE_NAME));
|
||||
} else {
|
||||
question_string.append(tr("Please, review your transaction."));
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
assert(m_current_transaction);
|
||||
|
||||
const QString confirmation = model->wallet().privateKeysDisabled() ? tr("Confirm transaction proposal") : tr("Confirm send coins");
|
||||
const QString confirmButtonText = model->wallet().privateKeysDisabled() ? tr("Copy PSBT to clipboard") : tr("Send");
|
||||
const QString confirmButtonText = model->wallet().privateKeysDisabled() ? tr("Create Unsigned") : tr("Send");
|
||||
SendConfirmationDialog confirmationDialog(confirmation, question_string, informative_text, detailed_text, SEND_CONFIRM_DELAY, confirmButtonText, this);
|
||||
confirmationDialog.exec();
|
||||
QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
|
||||
|
@ -403,7 +403,43 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
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);
|
||||
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,
|
||||
tr("Partially Signed Transaction (Binary) (*.psbt)"), &selectedFilter);
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
std::ofstream out(filename.toLocal8Bit().data());
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
// now send the prepared transaction
|
||||
WalletModel::SendCoinsReturn sendStatus = model->sendCoins(*m_current_transaction);
|
||||
|
@ -422,10 +458,13 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
coinControlUpdateLabels();
|
||||
}
|
||||
fNewRecipientAllowed = true;
|
||||
m_current_transaction.reset();
|
||||
}
|
||||
|
||||
void SendCoinsDialog::clear()
|
||||
{
|
||||
m_current_transaction.reset();
|
||||
|
||||
// Clear coin control settings
|
||||
CoinControlDialog::coinControl()->UnSelectAll();
|
||||
ui->checkBoxCoinControlChange->setChecked(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue