Ejemplo n.º 1
0
    def page7_sync_initialize_page(self):
        if self._mnemonic and not self._address:
            self._address = main_address_from_mnemonic(self._mnemonic)

        self.label_address.setText(self._address)
        img = ImageQt(qrcode.make(self._address, box_size=3))
        self.label_qr_code.setPixmap(QPixmap.fromImage(img))

        if not exists(app.DATA_DIR):
            self.log('Creating data dir at: %s' % app.DATA_DIR)
            init_data_dir()

        self.log('Initialize profile database at: %s' % app.PROFILE_DB_FILEPATH)

        if self._manage_node:
            init_profile_db(create_default_profile=True)
        elif self._connection_tested:
            init_profile_db(create_default_profile=False)
            p_obj, created = Profile.get_or_create(
                name=self.edit_rpc_host.text(),
                defaults=dict(
                    rpc_host=self.edit_rpc_host.text(),
                    rpc_port=self.edit_rpc_port.text(),
                    rpc_user=self.edit_rpc_user.text(),
                    rpc_password=self.edit_rpc_password.text(),
                    rpc_use_ssl=self.cbox_use_ssl.isChecked(),
                    manage_node=False,
                    exit_on_close=True,
                    active=True,
                )
            )

        self.log('Initialize node-sync database')
        init_data_db()

        if self._manage_node:
            self.node.start(initprivkey=main_wif_from_mnemonic(self._mnemonic))
        else:
            self._database_sync = True
            if not self.updater.isRunning():
                self.updater.start()