tln: use START_INDEX instead of 2**48-1 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 3c06b3cee1558d1e5d856a5cf34ffb3bb89c4e84 DIR parent a841fa3602372726186cd1e50477e5924966249a HTML Author: Janus <ysangkok@gmail.com> Date: Wed, 25 Jul 2018 14:00:22 +0200 ln: use START_INDEX instead of 2**48-1 Diffstat: M electrum/lnbase.py | 4 ++-- M electrum/tests/test_lnhtlc.py | 8 ++++---- M electrum/tests/test_lnutil.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) --- DIR diff --git a/electrum/lnbase.py b/electrum/lnbase.py t@@ -530,7 +530,7 @@ class Peer(PrintError): ) # TODO derive this? per_commitment_secret_seed = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100.to_bytes(32, 'big') - per_commitment_secret_index = 2**48 - 1 + per_commitment_secret_index = RevocationStore.START_INDEX # for the first commitment transaction per_commitment_secret_first = get_per_commitment_secret_from_seed(per_commitment_secret_seed, per_commitment_secret_index) per_commitment_point_first = secret_to_pubkey(int.from_bytes(per_commitment_secret_first, 'big')) t@@ -680,7 +680,7 @@ class Peer(PrintError): def funding_locked(self, chan): channel_id = chan.channel_id - per_commitment_secret_index = 2**48 - 2 + per_commitment_secret_index = RevocationStore.START_INDEX - 1 per_commitment_point_second = secret_to_pubkey(int.from_bytes( get_per_commitment_secret_from_seed(chan.local_state.per_commitment_secret_seed, per_commitment_secret_index), 'big')) self.send_message(gen_msg("funding_locked", channel_id=channel_id, next_per_commitment_point=per_commitment_point_second)) DIR diff --git a/electrum/tests/test_lnhtlc.py b/electrum/tests/test_lnhtlc.py t@@ -91,10 +91,10 @@ def create_test_channels(feerate=6000, local=None, remote=None): alice_seed = os.urandom(32) bob_seed = os.urandom(32) - alice_cur = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(alice_seed, 2**48 - 1), "big")) - alice_next = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(alice_seed, 2**48 - 2), "big")) - bob_cur = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(bob_seed, 2**48 - 1), "big")) - bob_next = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(bob_seed, 2**48 - 2), "big")) + alice_cur = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(alice_seed, lnutil.RevocationStore.START_INDEX), "big")) + alice_next = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(alice_seed, lnutil.RevocationStore.START_INDEX - 1), "big")) + bob_cur = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(bob_seed, lnutil.RevocationStore.START_INDEX), "big")) + bob_next = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(bob_seed, lnutil.RevocationStore.START_INDEX - 1), "big")) return \ lnhtlc.HTLCStateMachine( DIR diff --git a/electrum/tests/test_lnutil.py b/electrum/tests/test_lnutil.py t@@ -440,7 +440,7 @@ class TestLNUtil(unittest.TestCase): seed = bitcoin.sha256(b"shachaintest") consumer = RevocationStore() for i in range(10000): - secret = get_per_commitment_secret_from_seed(seed, 2**48 - i - 1) + secret = get_per_commitment_secret_from_seed(seed, RevocationStore.START_INDEX - i) try: consumer.add_next_entry(secret) except Exception as e: