URI: 
       tkivy channel dialog: fix unit of displayed feerate - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 6094f2751e658dbc2cc44b04455961a7046aaa3f
   DIR parent 7d7dcf07956fcc1ae32b76feecb58bee9913ef19
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Mon,  1 Mar 2021 17:09:04 +0100
       
       kivy channel dialog: fix unit of displayed feerate
       
       The amount shown was in sat/kw, incorrectly labeled as sat/kbyte.
       Show sat/vbyte instead.
       
       Diffstat:
         M electrum/gui/kivy/uix/dialogs/ligh… |       9 +++++----
         M electrum/lnhtlc.py                  |       3 ++-
         M electrum/transaction.py             |       5 +++++
       
       3 files changed, 12 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
       t@@ -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:
       t@@ -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:
       t@@ -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()
   DIR diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py
       t@@ -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)
   DIR diff --git a/electrum/transaction.py b/electrum/transaction.py
       t@@ -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: