Browse Source

kivy channel dialog: fix unit of displayed feerate

The amount shown was in sat/kw, incorrectly labeled as sat/kbyte.
Show sat/vbyte instead.
patch-4
SomberNight 4 years ago
parent
commit
6094f2751e
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 9
      electrum/gui/kivy/uix/dialogs/lightning_channels.py
  2. 3
      electrum/lnhtlc.py
  3. 5
      electrum/transaction.py

9
electrum/gui/kivy/uix/dialogs/lightning_channels.py

@ -12,8 +12,8 @@ from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
from electrum.lnchannel import AbstractChannel, Channel
from electrum.gui.kivy.i18n import _
from .question import Question
from electrum.transaction import PartialTxOutput
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis
from electrum.transaction import PartialTxOutput, Transaction
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis, quantize_feerate
from electrum.lnutil import ln_dummy_address
if TYPE_CHECKING:
@ -276,7 +276,7 @@ Builder.load_string(r'''
value: 'Local: %d\nRemote: %d' % (root.local_ctn, root.remote_ctn)
BoxLabel:
text: _('Fee rate')
value: '%d sat/kilobyte' % (root.feerate)
value: '{} sat/byte'.format(root.feerate)
Widget:
size_hint: 1, 0.1
TopLabel:
@ -467,7 +467,8 @@ class ChannelDetailsPopup(Popup, Logger):
self.local_csv = chan.config[LOCAL].to_self_delay
self.remote_csv = chan.config[REMOTE].to_self_delay
self.initiator = 'Local' if chan.constraints.is_initiator else 'Remote'
self.feerate = chan.get_latest_feerate(LOCAL)
feerate_kw = chan.get_latest_feerate(LOCAL)
self.feerate = str(quantize_feerate(Transaction.satperbyte_from_satperkw(feerate_kw)))
self.can_send = self.app.format_amount_and_units(chan.available_to_spend(LOCAL) // 1000)
self.can_receive = self.app.format_amount_and_units(chan.available_to_spend(REMOTE) // 1000)
self.is_open = chan.is_open()

3
electrum/lnhtlc.py

@ -537,10 +537,11 @@ class HTLCManager:
log_action='fails')
##### Queries re Fees:
# note: feerates are in sat/kw everywhere in this file
@with_lock
def get_feerate(self, subject: HTLCOwner, ctn: int) -> int:
"""Return feerate used in subject's commitment txn at ctn."""
"""Return feerate (sat/kw) used in subject's commitment txn at ctn."""
ctn = max(0, ctn) # FIXME rm this
# only one party can update fees; use length of logs to figure out which:
assert not (len(self.log[LOCAL]['fee_updates']) > 1 and len(self.log[REMOTE]['fee_updates']) > 1)

5
electrum/transaction.py

@ -909,6 +909,11 @@ class Transaction:
def virtual_size_from_weight(cls, weight):
return weight // 4 + (weight % 4 > 0)
@classmethod
def satperbyte_from_satperkw(cls, feerate_kw):
"""Converts feerate from sat/kw to sat/vbyte."""
return feerate_kw * 4 / 1000
def estimated_total_size(self):
"""Return an estimated total transaction size in bytes."""
if not self.is_complete() or self._cached_network_ser is None:

Loading…
Cancel
Save