You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.4 KiB

import sys
import json
import binascii
import asyncio
import time
from lib.constants import set_testnet, set_simnet
from lib.simple_config import SimpleConfig
from lib.network import Network
from lib.storage import WalletStorage
from lib.wallet import Wallet
from lib.lnbase import Peer, node_list
if __name__ == "__main__":
if len(sys.argv) > 2:
host, port, pubkey = sys.argv[2:5]
else:
host, port, pubkey = node_list[0]
pubkey = binascii.unhexlify(pubkey)
port = int(port)
if sys.argv[1] not in ["simnet", "testnet"]:
raise Exception("first argument must be simnet or testnet")
if sys.argv[1] == "simnet":
set_simnet()
config = SimpleConfig({'lnbase':True, 'simnet':True})
else:
set_testnet()
config = SimpleConfig({'lnbase':True, 'testnet':True})
# start network
network = Network(config)
network.start()
asyncio.set_event_loop(network.asyncio_loop)
# wallet
storage = WalletStorage(config.get_wallet_path())
wallet = Wallet(storage)
# start peer
peer = Peer(host, port, pubkey, request_initial_sync=False)
network.futures.append(asyncio.run_coroutine_threadsafe(peer.main_loop(), network.asyncio_loop))
# run blocking test
start = time.time()
coro = peer.channel_establishment_flow(wallet, config)
fut = asyncio.run_coroutine_threadsafe(coro, network.asyncio_loop)
while network.asyncio_loop.is_running():
time.sleep(1)