Browse Source

ln: use START_INDEX instead of 2**48-1

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 7 years ago
committed by ThomasV
parent
commit
3c06b3cee1
  1. 4
      electrum/lnbase.py
  2. 8
      electrum/tests/test_lnhtlc.py
  3. 2
      electrum/tests/test_lnutil.py

4
electrum/lnbase.py

@ -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'))
@ -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))

8
electrum/tests/test_lnhtlc.py

@ -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(

2
electrum/tests/test_lnutil.py

@ -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:

Loading…
Cancel
Save