mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
trivial: use "chunks()" for htlc_sigs in lnchannel
This commit is contained in:
parent
8ad6d5ddda
commit
db84de5493
3 changed files with 6 additions and 3 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue