| 411 | } |
| 412 | |
| 413 | void 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 | |
| 460 | bool SendCoinsDialog::signWithExternalSigner(PartiallySignedTransaction& psbtx, CMutableTransaction& mtx, bool& complete) { |
| 461 | TransactionError err; |
nothing calls this directly
no test coverage detected