| 514 | } |
| 515 | |
| 516 | bool WalletModel::bumpFee(uint256 hash, uint256& new_hash) |
| 517 | { |
| 518 | CCoinControl coin_control; |
| 519 | coin_control.m_signal_bip125_rbf = true; |
| 520 | std::vector<bilingual_str> errors; |
| 521 | CAmount old_fee; |
| 522 | CAmount new_fee; |
| 523 | CMutableTransaction mtx; |
| 524 | if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) { |
| 525 | QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" + |
| 526 | (errors.size() ? QString::fromStdString(errors[0].translated) : "") +")"); |
| 527 | return false; |
| 528 | } |
| 529 | |
| 530 | // allow a user based fee verification |
| 531 | /*: Asks a user if they would like to manually increase the fee of a transaction that has already been created. */ |
| 532 | QString questionString = tr("Do you want to increase the fee?"); |
| 533 | questionString.append("<br />"); |
| 534 | questionString.append("<table style=\"text-align: left;\">"); |
| 535 | questionString.append("<tr><td>"); |
| 536 | questionString.append(tr("Current fee:")); |
| 537 | questionString.append("</td><td>"); |
| 538 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee)); |
| 539 | questionString.append("</td></tr><tr><td>"); |
| 540 | questionString.append(tr("Increase:")); |
| 541 | questionString.append("</td><td>"); |
| 542 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee)); |
| 543 | questionString.append("</td></tr><tr><td>"); |
| 544 | questionString.append(tr("New fee:")); |
| 545 | questionString.append("</td><td>"); |
| 546 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee)); |
| 547 | questionString.append("</td></tr></table>"); |
| 548 | |
| 549 | // Display warning in the "Confirm fee bump" window if the "Coin Control Features" option is enabled |
| 550 | if (getOptionsModel()->getCoinControlFeatures()) { |
| 551 | questionString.append("<br><br>"); |
| 552 | 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.")); |
| 553 | } |
| 554 | |
| 555 | auto confirmationDialog = new SendConfirmationDialog(tr("Confirm fee bump"), questionString, "", "", SEND_CONFIRM_DELAY, !m_wallet->privateKeysDisabled(), getOptionsModel()->getEnablePSBTControls(), nullptr); |
| 556 | confirmationDialog->setAttribute(Qt::WA_DeleteOnClose); |
| 557 | // TODO: Replace QDialog::exec() with safer QDialog::show(). |
| 558 | const auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog->exec()); |
| 559 | |
| 560 | // cancel sign&broadcast if user doesn't want to bump the fee |
| 561 | if (retval != QMessageBox::Yes && retval != QMessageBox::Save) { |
| 562 | return false; |
| 563 | } |
| 564 | |
| 565 | WalletModel::UnlockContext ctx(requestUnlock()); |
| 566 | if(!ctx.isValid()) |
| 567 | { |
| 568 | return false; |
| 569 | } |
| 570 | |
| 571 | // Short-circuit if we are returning a bumped transaction PSBT to clipboard |
| 572 | if (retval == QMessageBox::Save) { |
| 573 | PartiallySignedTransaction psbtx(mtx); |
nothing calls this directly
no test coverage detected