1
0

wallet.bump_fee: the glorious return of BumpFeeStrategy :D

gui/qt/rbf_dialog.py (old) lines 57-64 were implementing logic that should not be part of GUI code.
Case in point, gui/qml/qetxfinalizer.py (old) lines 511-513 duplicated half of that logic but not the other half.
That logic is now moved to wallet.get_bumpfee_strategies_for_tx().

More context: a user on irc got confused when using the qml gui. They were sending "max" and wanted to bump_fee.
The qml gui selected the "preserve_payment" strategy by default, using which there was no solution, and the user
did not notice that the strategy can be altered (via the "method" dropdown). The qt gui had logic to select
"decrease_payment" by default in such a case (which does find a solution to bump) but this logic was not
duplicated in the qml gui.
Instead of duplicating the logic, this commit moves it to shared lib code.
This commit is contained in:
SomberNight
2023-11-20 18:00:23 +00:00
parent 03dd38bfb8
commit 7f64ecc4bd
6 changed files with 78 additions and 50 deletions

View File

@@ -12,7 +12,7 @@ from electrum import SimpleConfig
from electrum import util
from electrum.address_synchronizer import TX_HEIGHT_UNCONFIRMED, TX_HEIGHT_UNCONF_PARENT
from electrum.wallet import (sweep, Multisig_Wallet, Standard_Wallet, Imported_Wallet,
restore_wallet_from_text, Abstract_Wallet, CannotBumpFee)
restore_wallet_from_text, Abstract_Wallet, CannotBumpFee, BumpFeeStrategy)
from electrum.util import (
bfh, NotEnoughFunds, UnrelatedTransactionException,
UserFacingException)
@@ -1229,7 +1229,7 @@ class TestWalletSending(ElectrumTestCase):
tx = wallet.bump_fee(
tx=tx_from_any(orig_rbf_tx.serialize()),
new_fee_rate=60,
decrease_payment=True,
strategy=BumpFeeStrategy.DECREASE_PAYMENT,
)
tx.locktime = 1936085
tx.version = 2
@@ -1271,7 +1271,7 @@ class TestWalletSending(ElectrumTestCase):
tx = wallet.bump_fee(
tx=tx_from_any(orig_rbf_tx.serialize()),
new_fee_rate=60,
decrease_payment=True,
strategy=BumpFeeStrategy.DECREASE_PAYMENT,
)
tx.locktime = 1936095
tx.version = 2
@@ -1313,19 +1313,19 @@ class TestWalletSending(ElectrumTestCase):
tx = wallet.bump_fee(
tx=tx_from_any(orig_rbf_tx.serialize()),
new_fee_rate=99999,
decrease_payment=True,
strategy=BumpFeeStrategy.DECREASE_PAYMENT,
)
with self.assertRaises(CannotBumpFee):
tx = wallet.bump_fee(
tx=tx_from_any(orig_rbf_tx.serialize()),
new_fee_rate=99999,
decrease_payment=False,
strategy=BumpFeeStrategy.PRESERVE_PAYMENT,
)
tx = wallet.bump_fee(
tx=tx_from_any(orig_rbf_tx.serialize()),
new_fee_rate=60,
decrease_payment=True,
strategy=BumpFeeStrategy.DECREASE_PAYMENT,
)
tx.locktime = 1936085
tx.version = 2
@@ -1647,7 +1647,7 @@ class TestWalletSending(ElectrumTestCase):
self.assertEqual((0, 0, 0), wallet.get_balance())
# bump tx
tx = wallet.bump_fee(tx=tx_from_any(tx.serialize()), new_fee_rate=70.0, decrease_payment=True)
tx = wallet.bump_fee(tx=tx_from_any(tx.serialize()), new_fee_rate=70.0, strategy=BumpFeeStrategy.DECREASE_PAYMENT)
tx.locktime = 1325500
tx.version = 1
if simulate_moving_txs: