MCPcopy Create free account
hub / github.com/ElementsProject/elements / presentPSBT

Method presentPSBT

src/qt/sendcoinsdialog.cpp:413–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
414{
415 // Serialize the PSBT
416 CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
417 ssTx << psbtx;
418 GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
419 QMessageBox msgBox;
420 msgBox.setText("Unsigned Transaction");
421 msgBox.setInformativeText("The PSBT has been copied to the clipboard. You can also save it.");
422 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
423 msgBox.setDefaultButton(QMessageBox::Discard);
424 switch (msgBox.exec()) {
425 case QMessageBox::Save: {
426 int bitcoin_unit = model->getOptionsModel()->getDisplayUnit();
427 QString selectedFilter;
428 QString fileNameSuggestion = "";
429 bool first = true;
430 for (const SendAssetsRecipient &rcp : m_current_transaction->getRecipients()) {
431 if (!first) {
432 fileNameSuggestion.append(" - ");
433 }
434 QString labelOrAddress = rcp.label.isEmpty() ? rcp.address : rcp.label;
435 QString amount = GUIUtil::formatAssetAmount(rcp.asset, rcp.asset_amount, bitcoin_unit, BitcoinUnits::SeparatorStyle::STANDARD, true);
436 fileNameSuggestion.append(labelOrAddress + "-" + amount);
437 first = false;
438 }
439 fileNameSuggestion.append(".psbt");
440 QString filename = GUIUtil::getSaveFileName(this,
441 tr("Save Transaction Data"), fileNameSuggestion,
442 //: Expanded name of the binary PSBT file format. See: BIP 174.
443 tr("Partially Signed Transaction (Binary)") + QLatin1String(" (*.psbt)"), &selectedFilter);
444 if (filename.isEmpty()) {
445 return;
446 }
447 std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary};
448 out << ssTx.str();
449 out.close();
450 Q_EMIT message(tr("PSBT saved"), "PSBT saved to disk", CClientUIInterface::MSG_INFORMATION);
451 break;
452 }
453 case QMessageBox::Discard:
454 break;
455 default:
456 assert(false);
457 } // msgBox.exec()
458}
459
460bool SendCoinsDialog::signWithExternalSigner(PartiallySignedTransaction& psbtx, CMutableTransaction& mtx, bool& complete) {
461 TransactionError err;

Callers

nothing calls this directly

Calls 12

setClipboardFunction · 0.85
formatAssetAmountFunction · 0.85
getSaveFileNameFunction · 0.85
strMethod · 0.80
setTextMethod · 0.80
execMethod · 0.80
getDisplayUnitMethod · 0.80
getRecipientsMethod · 0.80
EncodeBase64Function · 0.50
getOptionsModelMethod · 0.45
dataMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected