Esempio n. 1
0
def lightning_proxy(args=None, datadir=DEFAULT_DATADIR, conf="lightning.conf"):
    """Return a lightning proxy pointing to the config."""
    lightning_conf = lightning_config(args, datadir, conf)
    return jsonrpcproxy.AuthProxy(
        'http://localhost:%d/local/' % lightning_conf.getint('port'),
        (lightning_conf.get('rpcuser'),
         lightning_conf.get('rpcpassword')))
Esempio n. 2
0
 def is_alive(self):
     """Check if the node is alive."""
     try:
         return self.proxy.alive()
     except requests.exceptions.ConnectionError:
         pass
     # Reinitialize proxy
     self.proxy = jsonrpcproxy.AuthProxy(
         'http://localhost:%d/local/' % self.port, ('rt', 'rt'))
     return False
Esempio n. 3
0
    def start(self):
        """Start the node."""
        self.logfile = open(os.path.join(self.datadir, 'lightning.log'), 'w')
        self.process = subprocess.Popen(
            [LIGHTNINGD, '-datadir=%s' % self.datadir, '-nodebug'],
            stdin=subprocess.DEVNULL,
            stdout=self.logfile,
            stderr=subprocess.STDOUT)

        self.proxy = jsonrpcproxy.AuthProxy(
            'http://localhost:%d/local/' % self.port, ('rt', 'rt'))