mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
fix fee ui: offline case
This commit is contained in:
parent
9d4dd20b23
commit
6f954090e6
3 changed files with 24 additions and 8 deletions
|
@ -44,7 +44,7 @@ from electrum.plugins import run_hook
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.util import (format_time, format_satoshis, PrintError,
|
from electrum.util import (format_time, format_satoshis, PrintError,
|
||||||
format_satoshis_plain, NotEnoughFunds,
|
format_satoshis_plain, NotEnoughFunds,
|
||||||
UserCancelled)
|
UserCancelled, NoDynamicFeeEstimates)
|
||||||
from electrum import Transaction
|
from electrum import Transaction
|
||||||
from electrum import util, bitcoin, commands, coinchooser
|
from electrum import util, bitcoin, commands, coinchooser
|
||||||
from electrum import paymentrequest
|
from electrum import paymentrequest
|
||||||
|
@ -1068,7 +1068,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
else:
|
else:
|
||||||
self.config.set_key('fee_per_kb', fee_rate, False)
|
self.config.set_key('fee_per_kb', fee_rate, False)
|
||||||
|
|
||||||
self.feerate_e.setAmount(fee_rate // 1000)
|
if fee_rate:
|
||||||
|
self.feerate_e.setAmount(fee_rate // 1000)
|
||||||
self.fee_e.setModified(False)
|
self.fee_e.setModified(False)
|
||||||
|
|
||||||
self.fee_slider.activate()
|
self.fee_slider.activate()
|
||||||
|
@ -1098,6 +1099,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
self.size_e = TxSizeLabel()
|
self.size_e = TxSizeLabel()
|
||||||
self.size_e.setAlignment(Qt.AlignCenter)
|
self.size_e.setAlignment(Qt.AlignCenter)
|
||||||
self.size_e.setAmount(0)
|
self.size_e.setAmount(0)
|
||||||
|
self.size_e.setFixedWidth(140)
|
||||||
self.size_e.setStyleSheet(ColorScheme.DEFAULT.as_stylesheet())
|
self.size_e.setStyleSheet(ColorScheme.DEFAULT.as_stylesheet())
|
||||||
|
|
||||||
self.feerate_e = FeerateEdit(lambda: 2 if self.fee_unit else 0)
|
self.feerate_e = FeerateEdit(lambda: 2 if self.fee_unit else 0)
|
||||||
|
@ -1242,17 +1244,24 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
if not outputs:
|
if not outputs:
|
||||||
_type, addr = self.get_payto_or_dummy()
|
_type, addr = self.get_payto_or_dummy()
|
||||||
outputs = [(_type, addr, amount)]
|
outputs = [(_type, addr, amount)]
|
||||||
try:
|
is_sweep = bool(self.tx_external_keypairs)
|
||||||
is_sweep = bool(self.tx_external_keypairs)
|
make_tx = lambda fee_est: \
|
||||||
tx = self.wallet.make_unsigned_transaction(
|
self.wallet.make_unsigned_transaction(
|
||||||
self.get_coins(), outputs, self.config,
|
self.get_coins(), outputs, self.config,
|
||||||
fixed_fee=fee_estimator, is_sweep=is_sweep)
|
fixed_fee=fee_est, is_sweep=is_sweep)
|
||||||
|
try:
|
||||||
|
tx = make_tx(fee_estimator)
|
||||||
self.not_enough_funds = False
|
self.not_enough_funds = False
|
||||||
except NotEnoughFunds:
|
except NotEnoughFunds:
|
||||||
self.not_enough_funds = True
|
self.not_enough_funds = True
|
||||||
if not freeze_fee:
|
if not freeze_fee:
|
||||||
self.fee_e.setAmount(None)
|
self.fee_e.setAmount(None)
|
||||||
return
|
return
|
||||||
|
except NoDynamicFeeEstimates:
|
||||||
|
tx = make_tx(0)
|
||||||
|
size = tx.estimated_size()
|
||||||
|
self.size_e.setAmount(size)
|
||||||
|
return
|
||||||
except BaseException:
|
except BaseException:
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
return
|
return
|
||||||
|
|
|
@ -47,6 +47,12 @@ def normalize_version(v):
|
||||||
|
|
||||||
class NotEnoughFunds(Exception): pass
|
class NotEnoughFunds(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoDynamicFeeEstimates(Exception):
|
||||||
|
def __str__(self):
|
||||||
|
return _('Dynamic fee estimates not available')
|
||||||
|
|
||||||
|
|
||||||
class InvalidPassword(Exception):
|
class InvalidPassword(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _("Incorrect password")
|
return _("Incorrect password")
|
||||||
|
|
|
@ -42,7 +42,8 @@ from numbers import Number
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .util import NotEnoughFunds, PrintError, UserCancelled, profiler, format_satoshis
|
from .util import (NotEnoughFunds, PrintError, UserCancelled, profiler,
|
||||||
|
format_satoshis, NoDynamicFeeEstimates)
|
||||||
|
|
||||||
from .bitcoin import *
|
from .bitcoin import *
|
||||||
from .version import *
|
from .version import *
|
||||||
|
@ -884,7 +885,7 @@ class Abstract_Wallet(PrintError):
|
||||||
raise NotEnoughFunds()
|
raise NotEnoughFunds()
|
||||||
|
|
||||||
if fixed_fee is None and config.fee_per_kb() is None:
|
if fixed_fee is None and config.fee_per_kb() is None:
|
||||||
raise BaseException('Dynamic fee estimates not available')
|
raise NoDynamicFeeEstimates()
|
||||||
|
|
||||||
for item in inputs:
|
for item in inputs:
|
||||||
self.add_input_info(item)
|
self.add_input_info(item)
|
||||||
|
|
Loading…
Add table
Reference in a new issue