| 462 | } |
| 463 | |
| 464 | bool WalletModel::bumpFee(Txid hash, Txid& new_hash) |
| 465 | { |
| 466 | CCoinControl coin_control; |
| 467 | std::vector<bilingual_str> errors; |
| 468 | CAmount old_fee; |
| 469 | CAmount new_fee; |
| 470 | CMutableTransaction mtx; |
| 471 | if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) { |
| 472 | QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" + |
| 473 | (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")"); |
| 474 | return false; |
| 475 | } |
| 476 | |
| 477 | // allow a user based fee verification |
| 478 | /*: Asks a user if they would like to manually increase the fee of a transaction that has already been created. */ |
| 479 | QString questionString = tr("Do you want to increase the fee?"); |
| 480 | questionString.append("<br />"); |
| 481 | questionString.append("<table style=\"text-align: left;\">"); |
| 482 | questionString.append("<tr><td>"); |
| 483 | questionString.append(tr("Current fee:")); |
| 484 | questionString.append("</td><td>"); |
| 485 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee)); |
| 486 | questionString.append("</td></tr><tr><td>"); |
| 487 | questionString.append(tr("Increase:")); |
| 488 | questionString.append("</td><td>"); |
| 489 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee)); |
| 490 | questionString.append("</td></tr><tr><td>"); |
| 491 | questionString.append(tr("New fee:")); |
| 492 | questionString.append("</td><td>"); |
| 493 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee)); |
| 494 | questionString.append("</td></tr></table>"); |
| 495 | |
| 496 | // Display warning in the "Confirm fee bump" window if the "Coin Control Features" option is enabled |
| 497 | if (getOptionsModel()->getCoinControlFeatures()) { |
| 498 | questionString.append("<br><br>"); |
| 499 | questionString.append(tr("Warning: This may pay the additional fee by reducing change outputs or adding inputs, when necessary. It may add a new change output if one does not already exist. These changes may potentially leak privacy.")); |
| 500 | } |
| 501 | |
| 502 | const bool enable_send{!wallet().privateKeysDisabled() || wallet().hasExternalSigner()}; |
| 503 | const bool always_show_unsigned{getOptionsModel()->getEnablePSBTControls()}; |
| 504 | auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, enable_send, always_show_unsigned, nullptr); |
| 505 | confirmationDialog->setAttribute(Qt::WA_DeleteOnClose); |
| 506 | // TODO: Replace QDialog::exec() with safer QDialog::show(). |
| 507 | const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec()); |
| 508 | |
| 509 | // cancel sign&broadcast if user doesn't want to bump the fee |
| 510 | if (retval != QMessageBox::Yes && retval != QMessageBox::Save) { |
| 511 | return false; |
| 512 | } |
| 513 | |
| 514 | // Short-circuit if we are returning a bumped transaction PSBT to clipboard |
| 515 | if (retval == QMessageBox::Save) { |
| 516 | // "Create Unsigned" clicked |
| 517 | PartiallySignedTransaction psbtx(mtx); |
| 518 | bool complete = false; |
| 519 | const auto err{wallet().fillPSBT({.sign = false, .bip32_derivs = true}, nullptr, psbtx, complete)}; |
| 520 | if (err || complete) { |
| 521 | QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Can't draft transaction.")); |
nothing calls this directly
no test coverage detected