mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
lnbase: add draft handlers
This commit is contained in:
parent
fc2864cb63
commit
d8eedf514d
1 changed files with 28 additions and 7 deletions
|
@ -288,15 +288,37 @@ class Peer(PrintError):
|
||||||
def process_message(self, message):
|
def process_message(self, message):
|
||||||
message_type, payload = decode_msg(message)
|
message_type, payload = decode_msg(message)
|
||||||
self.print_error("Received '%s'" % message_type.upper(), payload)
|
self.print_error("Received '%s'" % message_type.upper(), payload)
|
||||||
if message_type == 'ping':
|
try:
|
||||||
l = int.from_bytes(payload['num_pong_bytes'], byteorder="big")
|
f = getattr(self, 'on_' + message_type)
|
||||||
self.send_message(gen_msg('pong', byteslen=l))
|
except AttributeError:
|
||||||
elif message == 'channel_update':
|
return
|
||||||
pass
|
f(payload)
|
||||||
|
|
||||||
def open_channel(self):
|
def on_ping(self, payload):
|
||||||
|
l = int.from_bytes(payload['num_pong_bytes'], byteorder="big")
|
||||||
|
self.send_message(gen_msg('pong', byteslen=l))
|
||||||
|
|
||||||
|
def on_accept_channel(self, payload):
|
||||||
|
# check that it is in my pending requests
|
||||||
|
# I need to attach a wallet to each request
|
||||||
|
if ok:
|
||||||
|
tx = wallet.create_funding_tx()
|
||||||
|
wallet.sign(tx)
|
||||||
|
m = gen_msg('funding created', signature)
|
||||||
|
self.send_message(m)
|
||||||
|
|
||||||
|
def on_funding_signed(self, payload):
|
||||||
|
sig = payload['signature']
|
||||||
|
channel_id = payload['channel_id']
|
||||||
|
tx = self.channels[channel_id]
|
||||||
|
self.network.broadcast(tx)
|
||||||
|
|
||||||
|
def on_funding_locked(self, payload):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def open_channel(self, funding_sat, push_msat):
|
||||||
|
self.send_message(gen_msg('open_channel', funding_satoshis=funding_sat, push_msat=push_msat))
|
||||||
|
|
||||||
async def main_loop(self, loop):
|
async def main_loop(self, loop):
|
||||||
self.reader, self.writer = await asyncio.open_connection(self.host, self.port, loop=loop)
|
self.reader, self.writer = await asyncio.open_connection(self.host, self.port, loop=loop)
|
||||||
await self.handshake()
|
await self.handshake()
|
||||||
|
@ -345,4 +367,3 @@ if __name__ == "__main__":
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(peer.main_loop(loop))
|
loop.run_until_complete(peer.main_loop(loop))
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue