mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
lnbase: handle error during channel establishment
This commit is contained in:
parent
78119f9733
commit
7bd3cbf567
1 changed files with 11 additions and 3 deletions
|
@ -27,7 +27,8 @@ from .storage import WalletStorage
|
||||||
tcp_socket_timeout = 10
|
tcp_socket_timeout = 10
|
||||||
server_response_timeout = 60
|
server_response_timeout = 60
|
||||||
|
|
||||||
###############################
|
class LightningError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
message_types = {}
|
message_types = {}
|
||||||
|
|
||||||
|
@ -307,6 +308,9 @@ class Peer(PrintError):
|
||||||
return
|
return
|
||||||
f(payload)
|
f(payload)
|
||||||
|
|
||||||
|
def on_error(self, payload):
|
||||||
|
self.temporary_channel_id_to_incoming_accept_channel[payload["channel_id"]].set_exception(LightningError(payload["data"]))
|
||||||
|
|
||||||
def on_ping(self, payload):
|
def on_ping(self, payload):
|
||||||
l = int.from_bytes(payload['num_pong_bytes'], byteorder="big")
|
l = int.from_bytes(payload['num_pong_bytes'], byteorder="big")
|
||||||
self.send_message(gen_msg('pong', byteslen=l))
|
self.send_message(gen_msg('pong', byteslen=l))
|
||||||
|
@ -352,7 +356,11 @@ class Peer(PrintError):
|
||||||
msg = gen_msg("open_channel", temporary_channel_id=temp_channel_id, chain_hash=bytes.fromhex(rev_hex(constants.net.GENESIS)), funding_satoshis=20000, max_accepted_htlcs=5, funding_pubkey=next(pubkeys), revocation_basepoint=next(pubkeys), htlc_basepoint=next(pubkeys), payment_basepoint=next(pubkeys), delayed_payment_basepoint=next(pubkeys), first_per_commitment_point=next(pubkeys))
|
msg = gen_msg("open_channel", temporary_channel_id=temp_channel_id, chain_hash=bytes.fromhex(rev_hex(constants.net.GENESIS)), funding_satoshis=20000, max_accepted_htlcs=5, funding_pubkey=next(pubkeys), revocation_basepoint=next(pubkeys), htlc_basepoint=next(pubkeys), payment_basepoint=next(pubkeys), delayed_payment_basepoint=next(pubkeys), first_per_commitment_point=next(pubkeys))
|
||||||
self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id] = asyncio.Future()
|
self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id] = asyncio.Future()
|
||||||
self.send_message(msg)
|
self.send_message(msg)
|
||||||
|
try:
|
||||||
accept_channel = await self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
accept_channel = await self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
||||||
|
except LightningError:
|
||||||
|
return
|
||||||
|
finally:
|
||||||
del self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
del self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
||||||
|
|
||||||
# check that it is in my pending requests
|
# check that it is in my pending requests
|
||||||
|
|
Loading…
Add table
Reference in a new issue