URI: 
       ttrivial: use "chunks()" for htlc_sigs in lnchannel - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit db84de5493604a956c6d6492e7098e367b4b573f
   DIR parent 8ad6d5dddadda3df05da06a6a5634a8ebc5a8493
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Mon, 30 Mar 2020 02:42:07 +0200
       
       ttrivial: use "chunks()" for htlc_sigs in lnchannel
       
       Diffstat:
         M electrum/lnchannel.py               |       4 ++--
         M electrum/lnpeer.py                  |       2 +-
         M electrum/tests/test_util.py         |       3 +++
       
       3 files changed, 6 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py
       t@@ -32,7 +32,7 @@ import attr
        
        from . import ecc
        from . import constants
       -from .util import bfh, bh2u
       +from .util import bfh, bh2u, chunks
        from .bitcoin import redeem_script_to_address
        from .crypto import sha256, sha256d
        from .transaction import Transaction, PartialTransaction
       t@@ -628,7 +628,7 @@ class Channel(Logger):
        
            def get_remote_htlc_sig_for_htlc(self, *, htlc_relative_idx: int) -> bytes:
                data = self.config[LOCAL].current_htlc_signatures
       -        htlc_sigs = [data[i:i + 64] for i in range(0, len(data), 64)]
       +        htlc_sigs = list(chunks(data, 64))
                htlc_sig = htlc_sigs[htlc_relative_idx]
                remote_htlc_sig = ecc.der_sig_from_sig_string(htlc_sig) + b'\x01'
                return remote_htlc_sig
   DIR diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
       t@@ -1076,7 +1076,7 @@ class Peer(Logger):
                if chan.hm.is_revack_pending(LOCAL):
                    raise RemoteMisbehaving('received commitment_signed before we revoked previous ctx')
                data = payload["htlc_signature"]
       -        htlc_sigs = [data[i:i+64] for i in range(0, len(data), 64)]
       +        htlc_sigs = list(chunks(data, 64))
                chan.receive_new_commitment(payload["signature"], htlc_sigs)
                self.send_revoke_and_ack(chan)
        
   DIR diff --git a/electrum/tests/test_util.py b/electrum/tests/test_util.py
       t@@ -108,6 +108,9 @@ class TestUtil(ElectrumTestCase):
            def test_chunks(self):
                self.assertEqual([[1, 2], [3, 4], [5]],
                                 list(chunks([1, 2, 3, 4, 5], 2)))
       +        self.assertEqual([], list(chunks(b'', 64)))
       +        self.assertEqual([b'12', b'34', b'56'],
       +                         list(chunks(b'123456', 2)))
                with self.assertRaises(ValueError):
                    list(chunks([1, 2, 3], 0))