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)

        with profile_session_scope() as session:
            if self._manage_node:
                Profile.create_default_profile(session)
            elif self._connection_tested:
                session.merge(
                    Profile(
                        name=self.edit_rpc_host.text(),
                        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()

        # This fixes our problem with the locked database
        # We have no idea why, but we shouldn't delete this code until we have a better solution
        with data_session_scope() as session:
            session.query('DELETE FROM mining_reward')

        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()