def check(self):
        self.lnddir = LND_DIR_PATH[OPERATING_SYSTEM]

        # Previous versions of the launcher set lnddir in the config file,
        # but it is not a valid key so this helps old users upgrading
        if self.file['lnddir'] is not None:
            self.file['lnddir'] = None

        if self.file['debuglevel'] is None:
            self.file['debuglevel'] = 'info'

        self.file['bitcoin.active'] = True
        self.file['bitcoin.node'] = 'bitcoind'
        bitcoind_conf = BitcoindConfiguration()
        bitcoind_conf.load()
        self.file['bitcoind.rpchost'] = f'127.0.0.1:{bitcoind_conf.rpc_port}'
        self.file['bitcoind.rpcuser'] = bitcoind_conf.file['rpcuser']
        self.file['bitcoind.rpcpass'] = bitcoind_conf.file['rpcpassword']
        self.file['bitcoind.zmqpubrawblock'] = bitcoind_conf.file[
            'zmqpubrawblock']
        self.file['bitcoind.zmqpubrawtx'] = bitcoind_conf.file['zmqpubrawtx']

        if self.file['restlisten'] is None:
            self.rest_port = get_port(LND_DEFAULT_REST_PORT)
            self.file['restlisten'] = f'127.0.0.1:{self.rest_port}'
        else:
            self.rest_port = self.file['restlisten'].split(':')[-1]

        if not self.file['rpclisten']:
            self.grpc_port = get_port(LND_DEFAULT_GRPC_PORT)
            self.file['rpclisten'] = f'127.0.0.1:{self.grpc_port}'
        else:
            self.grpc_port = int(self.file['rpclisten'].split(':')[-1])

        if not self.file['tlsextraip']:
            self.file['tlsextraip'] = '127.0.0.1'

        if self.file['color'] is None:
            self.file['color'] = '#000000'

        self.file['tor.active'] = True
        self.file['tor.v3'] = True
        self.file['tor.streamisolation'] = True

        self.macaroon_path = os.path.join(self.lnddir, 'data', 'chain',
                                          'bitcoin', 'mainnet')
        self.config_snapshot = self.file.snapshot.copy()
        # self.file.file_watcher.fileChanged.connect(self.config_file_changed)
        # self.file.file_watcher.fileChanged.connect(
        #     self.bitcoin_config_file_changed)

        hostname_file = os.path.join(TOR_SERVICE_PATH, 'hostname')
        with open(hostname_file, 'r') as f:
            self.file['externalip'] = f.readline().strip()
Beispiel #2
0
 def node_port(self) -> int:
     if self['listen'] is None:
         port = get_port(LND_DEFAULT_PEER_PORT)
         self['listen'] = f'127.0.0.1:{port}'
     else:
         if not isinstance(self['listen'], list):
             port = int(self['listen'].split(':')[-1])
         else:
             port = int(self['listen'][0].split(':')[-1])
     return port