ln: use START_INDEX instead of 2**48-1
This commit is contained in:
@@ -530,7 +530,7 @@ class Peer(PrintError):
|
|||||||
)
|
)
|
||||||
# TODO derive this?
|
# TODO derive this?
|
||||||
per_commitment_secret_seed = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100.to_bytes(32, 'big')
|
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
|
# 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_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'))
|
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):
|
def funding_locked(self, chan):
|
||||||
channel_id = chan.channel_id
|
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(
|
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'))
|
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))
|
self.send_message(gen_msg("funding_locked", channel_id=channel_id, next_per_commitment_point=per_commitment_point_second))
|
||||||
|
|||||||
@@ -91,10 +91,10 @@ def create_test_channels(feerate=6000, local=None, remote=None):
|
|||||||
alice_seed = os.urandom(32)
|
alice_seed = os.urandom(32)
|
||||||
bob_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_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, 2**48 - 2), "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, 2**48 - 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, 2**48 - 2), "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 \
|
return \
|
||||||
lnhtlc.HTLCStateMachine(
|
lnhtlc.HTLCStateMachine(
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ class TestLNUtil(unittest.TestCase):
|
|||||||
seed = bitcoin.sha256(b"shachaintest")
|
seed = bitcoin.sha256(b"shachaintest")
|
||||||
consumer = RevocationStore()
|
consumer = RevocationStore()
|
||||||
for i in range(10000):
|
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:
|
try:
|
||||||
consumer.add_next_entry(secret)
|
consumer.add_next_entry(secret)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user