| 501 | } |
| 502 | |
| 503 | bool WalletModel::bumpFee(uint256 hash) |
| 504 | { |
| 505 | CCoinControl coin_control; |
| 506 | coin_control.m_signal_bip125_rbf = true; |
| 507 | std::vector<std::string> errors; |
| 508 | CAmount old_fee; |
| 509 | CAmount new_fee; |
| 510 | CMutableTransaction mtx; |
| 511 | if (!m_wallet->createBumpTransaction(hash, coin_control, 0 /* totalFee */, errors, old_fee, new_fee, mtx)) { |
| 512 | QMessageBox::critical(0, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" + |
| 513 | (errors.size() ? QString::fromStdString(errors[0]) : "") +")"); |
| 514 | return false; |
| 515 | } |
| 516 | |
| 517 | // allow a user based fee verification |
| 518 | QString questionString = tr("Do you want to increase the fee?"); |
| 519 | questionString.append("<br />"); |
| 520 | questionString.append("<table style=\"text-align: left;\">"); |
| 521 | questionString.append("<tr><td>"); |
| 522 | questionString.append(tr("Current fee:")); |
| 523 | questionString.append("</td><td>"); |
| 524 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee)); |
| 525 | questionString.append("</td></tr><tr><td>"); |
| 526 | questionString.append(tr("Increase:")); |
| 527 | questionString.append("</td><td>"); |
| 528 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee)); |
| 529 | questionString.append("</td></tr><tr><td>"); |
| 530 | questionString.append(tr("New fee:")); |
| 531 | questionString.append("</td><td>"); |
| 532 | questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee)); |
| 533 | questionString.append("</td></tr></table>"); |
| 534 | SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString); |
| 535 | confirmationDialog.exec(); |
| 536 | QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result()); |
| 537 | |
| 538 | // cancel sign&broadcast if user doesn't want to bump the fee |
| 539 | if (retval != QMessageBox::Yes) { |
| 540 | return false; |
| 541 | } |
| 542 | |
| 543 | WalletModel::UnlockContext ctx(requestUnlock()); |
| 544 | if(!ctx.isValid()) |
| 545 | { |
| 546 | return false; |
| 547 | } |
| 548 | |
| 549 | // sign bumped transaction |
| 550 | if (!m_wallet->signBumpTransaction(mtx)) { |
| 551 | QMessageBox::critical(0, tr("Fee bump error"), tr("Can't sign transaction.")); |
| 552 | return false; |
| 553 | } |
| 554 | // commit the bumped transaction |
| 555 | uint256 txid; |
| 556 | if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, txid)) { |
| 557 | QMessageBox::critical(0, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" + |
| 558 | QString::fromStdString(errors[0])+")"); |
| 559 | return false; |
| 560 | } |
nothing calls this directly
no test coverage detected