Browse Source
trivial: use "chunks()" for htlc_sigs in lnchannel
hard-fail-on-bad-server-string
SomberNight
5 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with
6 additions and
3 deletions
-
electrum/lnchannel.py
-
electrum/lnpeer.py
-
electrum/tests/test_util.py
|
|
@ -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 |
|
|
@ -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 |
|
|
|
|
|
@ -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) |
|
|
|
|
|
|
|
|
|
@ -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)) |
|
|
|
|
|
|
|