mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
integrate lnbase with network
This commit is contained in:
parent
a774aeaf8c
commit
6e6cec3097
2 changed files with 22 additions and 7 deletions
|
@ -935,7 +935,8 @@ def add_global_options(parser):
|
|||
group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet")
|
||||
group.add_argument("--regtest", action="store_true", dest="regtest", default=False, help="Use Regtest")
|
||||
group.add_argument("--simnet", action="store_true", dest="simnet", default=False, help="Use Simnet")
|
||||
group.add_argument("--lightning", action="store_true", dest="lightning", default=False, help="Enable Lightning support")
|
||||
group.add_argument("--lightning", action="store_true", dest="lightning", default=False, help="Enable Lightning support via hub")
|
||||
group.add_argument("--lnbase", action="store_true", dest="lnbase", default=False, help="Enable Lightning support")
|
||||
|
||||
def get_parser():
|
||||
# create main parser
|
||||
|
|
|
@ -18,6 +18,7 @@ import cryptography.hazmat.primitives.ciphers.aead as AEAD
|
|||
from electrum.bitcoin import public_key_from_private_key, ser_to_point, point_to_ser, string_to_number
|
||||
from electrum.bitcoin import int_to_hex, bfh, rev_hex
|
||||
from electrum.util import PrintError
|
||||
from electrum.wallet import Wallet
|
||||
|
||||
tcp_socket_timeout = 10
|
||||
server_response_timeout = 60
|
||||
|
@ -111,7 +112,6 @@ def gen_msg(msg_type, **kwargs):
|
|||
data += param
|
||||
return data
|
||||
|
||||
###############################
|
||||
|
||||
|
||||
def decode(string):
|
||||
|
@ -309,6 +309,9 @@ class Peer(PrintError):
|
|||
elif message == 'channel_update':
|
||||
pass
|
||||
|
||||
def open_channel(self):
|
||||
pass
|
||||
|
||||
async def main_loop(self, loop):
|
||||
self.reader, self.writer = await asyncio.open_connection(self.host, self.port, loop=loop)
|
||||
await self.handshake()
|
||||
|
@ -323,12 +326,20 @@ class Peer(PrintError):
|
|||
msg = await self.read_message()
|
||||
self.process_message(msg)
|
||||
# close socket
|
||||
self.print_error('closing lnbase')
|
||||
self.writer.close()
|
||||
|
||||
|
||||
# replacement for lightningCall
|
||||
class LNWallet(Wallet):
|
||||
|
||||
def run(self):
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(self.main_loop(loop))
|
||||
loop.close()
|
||||
def __init__(self, wallet, peer):
|
||||
self.wallet = wallet
|
||||
self.peer = peer
|
||||
|
||||
def openchannel(self):
|
||||
# todo: get utxo from wallet
|
||||
self.peer.open_channel()
|
||||
|
||||
|
||||
node_list = [
|
||||
|
@ -346,4 +357,7 @@ if __name__ == "__main__":
|
|||
port = int(port)
|
||||
privkey = b"\x21"*32 + b"\x01"
|
||||
peer = Peer(privkey, host, port, pubkey)
|
||||
peer.run()
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(peer.main_loop(loop))
|
||||
loop.close()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue