commit 3c06b3cee1558d1e5d856a5cf34ffb3bb89c4e84
parent a841fa3602372726186cd1e50477e5924966249a
Author: Janus <ysangkok@gmail.com>
Date: Wed, 25 Jul 2018 14:00:22 +0200
ln: use START_INDEX instead of 2**48-1
Diffstat:
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/electrum/lnbase.py b/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))
diff --git a/electrum/tests/test_lnhtlc.py b/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(
diff --git a/electrum/tests/test_lnutil.py b/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: