mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
add processing flow for funding_locked
This commit is contained in:
parent
2d305bd218
commit
a4809245b3
1 changed files with 27 additions and 3 deletions
|
@ -458,6 +458,8 @@ class Peer(PrintError):
|
||||||
self.ping_time = 0
|
self.ping_time = 0
|
||||||
self.channel_accepted = {}
|
self.channel_accepted = {}
|
||||||
self.funding_signed = {}
|
self.funding_signed = {}
|
||||||
|
self.local_funding_locked = {}
|
||||||
|
self.remote_funding_locked = {}
|
||||||
self.initialized = asyncio.Future()
|
self.initialized = asyncio.Future()
|
||||||
self.localfeatures = (0x08 if request_initial_sync else 0)
|
self.localfeatures = (0x08 if request_initial_sync else 0)
|
||||||
# view of the network
|
# view of the network
|
||||||
|
@ -584,7 +586,8 @@ class Peer(PrintError):
|
||||||
self.funding_signed[channel_id].set_result(payload)
|
self.funding_signed[channel_id].set_result(payload)
|
||||||
|
|
||||||
def on_funding_locked(self, payload):
|
def on_funding_locked(self, payload):
|
||||||
pass
|
channel_id = int.from_bytes(payload['channel_id'], byteorder="big")
|
||||||
|
self.funding_locked[channel_id].set_result(payload)
|
||||||
|
|
||||||
def on_node_announcement(self, payload):
|
def on_node_announcement(self, payload):
|
||||||
pubkey = payload['node_id']
|
pubkey = payload['node_id']
|
||||||
|
@ -752,7 +755,7 @@ class Peer(PrintError):
|
||||||
del self.funding_signed[channel_id]
|
del self.funding_signed[channel_id]
|
||||||
self.print_error('received funding_signed')
|
self.print_error('received funding_signed')
|
||||||
remote_sig = payload['signature']
|
remote_sig = payload['signature']
|
||||||
# todo: check signature agains local ctx
|
# todo: check signature against local ctx
|
||||||
local_ctx = make_commitment(
|
local_ctx = make_commitment(
|
||||||
ctn,
|
ctn,
|
||||||
funding_pubkey, remote_funding_pubkey,
|
funding_pubkey, remote_funding_pubkey,
|
||||||
|
@ -761,10 +764,31 @@ class Peer(PrintError):
|
||||||
revocation_pubkey, local_delayedpubkey,
|
revocation_pubkey, local_delayedpubkey,
|
||||||
funding_txid, funding_index, funding_satoshis,
|
funding_txid, funding_index, funding_satoshis,
|
||||||
local_amount, remote_amount, to_self_delay, dust_limit_satoshis)
|
local_amount, remote_amount, to_self_delay, dust_limit_satoshis)
|
||||||
|
# return for now
|
||||||
|
print('Done')
|
||||||
|
return
|
||||||
# broadcast funding tx
|
# broadcast funding tx
|
||||||
#self.network.broadcast(funding_tx)
|
self.local_funding_locked[channel_id] = asyncio.Future()
|
||||||
|
self.remote_funding_locked[channel_id] = asyncio.Future()
|
||||||
|
self.network.broadcast(funding_tx)
|
||||||
|
# wait until we see confirmations
|
||||||
|
try:
|
||||||
|
await self.local_funding_locked[channel_id]
|
||||||
|
finally:
|
||||||
|
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))
|
||||||
|
# wait until we receive funding_locked
|
||||||
|
try:
|
||||||
|
payload = await self.remote_funding_locked[channel_id]
|
||||||
|
finally:
|
||||||
|
del self.remote_funding_locked[channel_id]
|
||||||
self.print_error('Done')
|
self.print_error('Done')
|
||||||
|
|
||||||
|
def on_update_add_htlc(self, payload):
|
||||||
|
# no onion routing for the moment: we assume we are the end node
|
||||||
|
self.print_error('on_update_htlc')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# replacement for lightningCall
|
# replacement for lightningCall
|
||||||
class LNWorker:
|
class LNWorker:
|
||||||
|
|
Loading…
Add table
Reference in a new issue