mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-10 12:39:51 +00:00
channel_establishment_flow: use get_per_commitment_secret_from_seed
This commit is contained in:
parent
e76f7a2ca8
commit
38edf1ee64
1 changed files with 16 additions and 8 deletions
|
@ -684,7 +684,8 @@ class Peer(PrintError):
|
||||||
htlc_basepoint, htlc_privkey = next(keys)
|
htlc_basepoint, htlc_privkey = next(keys)
|
||||||
delayed_payment_basepoint, delayed_privkey = next(keys)
|
delayed_payment_basepoint, delayed_privkey = next(keys)
|
||||||
base_secret = 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
|
base_secret = 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
|
||||||
per_commitment_secret = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100
|
per_commitment_secret_seed = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100.to_bytes(length=32, byteorder="big")
|
||||||
|
per_commitment_secret_index = 2**48 - 1
|
||||||
# amounts
|
# amounts
|
||||||
funding_satoshis = 200000
|
funding_satoshis = 200000
|
||||||
push_msat = 0
|
push_msat = 0
|
||||||
|
@ -694,7 +695,9 @@ class Peer(PrintError):
|
||||||
ctn = 0
|
ctn = 0
|
||||||
#
|
#
|
||||||
base_point = secret_to_pubkey(base_secret)
|
base_point = secret_to_pubkey(base_secret)
|
||||||
per_commitment_point = secret_to_pubkey(per_commitment_secret)
|
per_commitment_point_first = secret_to_pubkey(int.from_bytes(
|
||||||
|
get_per_commitment_secret_from_seed(per_commitment_secret_seed, per_commitment_secret_index),
|
||||||
|
byteorder="big"))
|
||||||
msg = gen_msg(
|
msg = gen_msg(
|
||||||
"open_channel",
|
"open_channel",
|
||||||
temporary_channel_id=temp_channel_id,
|
temporary_channel_id=temp_channel_id,
|
||||||
|
@ -709,7 +712,7 @@ class Peer(PrintError):
|
||||||
htlc_basepoint=htlc_basepoint,
|
htlc_basepoint=htlc_basepoint,
|
||||||
payment_basepoint=base_point,
|
payment_basepoint=base_point,
|
||||||
delayed_payment_basepoint=delayed_payment_basepoint,
|
delayed_payment_basepoint=delayed_payment_basepoint,
|
||||||
first_per_commitment_point=per_commitment_point,
|
first_per_commitment_point=per_commitment_point_first,
|
||||||
to_self_delay=to_self_delay
|
to_self_delay=to_self_delay
|
||||||
)
|
)
|
||||||
self.channel_accepted[temp_channel_id] = asyncio.Future()
|
self.channel_accepted[temp_channel_id] = asyncio.Future()
|
||||||
|
@ -728,6 +731,7 @@ class Peer(PrintError):
|
||||||
funding_txn_minimum_depth = int.from_bytes(payload['minimum_depth'], byteorder="big")
|
funding_txn_minimum_depth = int.from_bytes(payload['minimum_depth'], byteorder="big")
|
||||||
self.print_error('remote dust limit', remote_dust_limit_satoshis)
|
self.print_error('remote dust limit', remote_dust_limit_satoshis)
|
||||||
self.print_error('remote delay', remote_delay)
|
self.print_error('remote delay', remote_delay)
|
||||||
|
self.print_error('funding_txn_minimum_depth', funding_txn_minimum_depth)
|
||||||
# create funding tx
|
# create funding tx
|
||||||
pubkeys = sorted([bh2u(funding_pubkey), bh2u(remote_funding_pubkey)])
|
pubkeys = sorted([bh2u(funding_pubkey), bh2u(remote_funding_pubkey)])
|
||||||
redeem_script = transaction.multisig_script(pubkeys, 2)
|
redeem_script = transaction.multisig_script(pubkeys, 2)
|
||||||
|
@ -739,11 +743,11 @@ class Peer(PrintError):
|
||||||
# derive keys
|
# derive keys
|
||||||
localpubkey = derive_pubkey(base_point, remote_per_commitment_point)
|
localpubkey = derive_pubkey(base_point, remote_per_commitment_point)
|
||||||
localprivkey = derive_privkey(base_secret, remote_per_commitment_point)
|
localprivkey = derive_privkey(base_secret, remote_per_commitment_point)
|
||||||
remotepubkey = derive_pubkey(remote_payment_basepoint, per_commitment_point)
|
remotepubkey = derive_pubkey(remote_payment_basepoint, per_commitment_point_first)
|
||||||
revocation_pubkey = derive_blinded_pubkey(revocation_basepoint, remote_per_commitment_point)
|
revocation_pubkey = derive_blinded_pubkey(revocation_basepoint, remote_per_commitment_point)
|
||||||
remote_revocation_pubkey = derive_blinded_pubkey(remote_revocation_basepoint, per_commitment_point)
|
remote_revocation_pubkey = derive_blinded_pubkey(remote_revocation_basepoint, per_commitment_point_first)
|
||||||
local_delayedpubkey = derive_pubkey(delayed_payment_basepoint, remote_per_commitment_point)
|
local_delayedpubkey = derive_pubkey(delayed_payment_basepoint, remote_per_commitment_point)
|
||||||
remote_delayedpubkey = derive_pubkey(remote_delayed_payment_basepoint, per_commitment_point)
|
remote_delayedpubkey = derive_pubkey(remote_delayed_payment_basepoint, per_commitment_point_first)
|
||||||
# compute amounts
|
# compute amounts
|
||||||
htlcs = []
|
htlcs = []
|
||||||
fee = local_feerate * overall_weight(len(htlcs)) // 1000
|
fee = local_feerate * overall_weight(len(htlcs)) // 1000
|
||||||
|
@ -814,13 +818,17 @@ class Peer(PrintError):
|
||||||
await self.local_funding_locked[channel_id]
|
await self.local_funding_locked[channel_id]
|
||||||
finally:
|
finally:
|
||||||
del self.local_funding_locked[channel_id]
|
del self.local_funding_locked[channel_id]
|
||||||
self.send_message(gen_msg("funding_locked", channel_id=channel_id, next_per_commitment_point=next_per_commitment_point))
|
per_commitment_secret_index -= 1
|
||||||
|
per_commitment_point_second = secret_to_pubkey(int.from_bytes(
|
||||||
|
get_per_commitment_secret_from_seed(per_commitment_secret_seed, per_commitment_secret_index),
|
||||||
|
byteorder="big"))
|
||||||
|
self.send_message(gen_msg("funding_locked", channel_id=channel_id, next_per_commitment_point=per_commitment_point_second))
|
||||||
# wait until we receive funding_locked
|
# wait until we receive funding_locked
|
||||||
try:
|
try:
|
||||||
payload = await self.remote_funding_locked[channel_id]
|
payload = await self.remote_funding_locked[channel_id]
|
||||||
finally:
|
finally:
|
||||||
del self.remote_funding_locked[channel_id]
|
del self.remote_funding_locked[channel_id]
|
||||||
self.print_error('Done waiting for remote_funding_locked')
|
self.print_error('Done waiting for remote_funding_locked', payload)
|
||||||
|
|
||||||
def on_update_add_htlc(self, payload):
|
def on_update_add_htlc(self, payload):
|
||||||
# no onion routing for the moment: we assume we are the end node
|
# no onion routing for the moment: we assume we are the end node
|
||||||
|
|
Loading…
Add table
Reference in a new issue