1
0

wallet: make "increase fee" RBF logic smarter

There are now two internal strategies to bump the fee of a txn.
bump fee method 1: keep all inputs, keep all not is_mine outputs,
                   allow adding new inputs
bump fee method 2: keep all inputs, no new inputs are added,
                   allow decreasing and removing outputs (change is decreased first)
Method 2 is less "safe" as it might end up decreasing e.g. a payment to a merchant;
but e.g. if the user has sent "Max" previously, this is the only way to RBF.

We try method 1 first, and fail-over to method 2.
Previous versions always used method 2.

fixes #3652
This commit is contained in:
SomberNight
2019-06-20 18:37:22 +02:00
parent 8bfe12e047
commit d0a43662bd
5 changed files with 122 additions and 44 deletions

View File

@@ -15,6 +15,7 @@ from electrum.gui.kivy.i18n import _
from electrum.util import InvalidPassword
from electrum.address_synchronizer import TX_HEIGHT_LOCAL
from electrum.wallet import CannotBumpFee
Builder.load_string('''
@@ -212,16 +213,14 @@ class TxDialog(Factory.Popup):
d = BumpFeeDialog(self.app, fee, size, self._do_rbf)
d.open()
def _do_rbf(self, old_fee, new_fee, is_final):
if new_fee is None:
return
delta = new_fee - old_fee
if delta < 0:
self.app.show_error("fee too low")
def _do_rbf(self, new_fee_rate, is_final):
if new_fee_rate is None:
return
try:
new_tx = self.wallet.bump_fee(self.tx, delta)
except BaseException as e:
new_tx = self.wallet.bump_fee(tx=self.tx,
new_fee_rate=new_fee_rate,
config=self.app.electrum_config)
except CannotBumpFee as e:
self.app.show_error(str(e))
return
if is_final: