Exemplo n.º 1
0
    def setupUi(self):
        Ui_TransactionDlg.setupUi(self, self)
        self.setWindowTitle('Transaction')
        self.chb_word_wrap.setChecked(
            app_cache.get_value(CACHE_ITEM_DETAILS_WORD_WRAP, False, bool))
        self.apply_word_wrap(self.chb_word_wrap.isChecked())
        self.edt_recipients.setOpenExternalLinks(True)
        self.edt_recipients.viewport().setAutoFillBackground(False)

        if sys.platform == 'win32':
            self.base_font_size = '8'
            self.title_font_size = '12'
        elif sys.platform == 'linux':
            self.base_font_size = '8'
            self.title_font_size = '14'
        else:  # mac
            self.base_font_size = '10'
            self.title_font_size = '17'

        self.edt_raw_transaction.setStyleSheet(
            f'font: {self.base_font_size}pt "Courier New";')
        doc = QTextDocument(self)
        doc.setDocumentMargin(0)
        doc.setHtml(
            f'<span style=" font-size:{self.title_font_size}pt;white-space:nowrap">AAAAAAAAAAAAAAAAAA'
        )
        default_width = int(doc.size().width()) * 3
        default_height = int(default_width / 2)

        app_cache.restore_window_size(self,
                                      default_width=default_width,
                                      default_height=default_height)
        self.prepare_tx_view()
Exemplo n.º 2
0
 def restore_cache_settings(self):
     app_cache.restore_window_size(self)
     self.show_manual_commands = app_cache.get_value(
         CACHE_ITEM_SHOW_COMMANDS, False, bool)
 def restore_cache_settings(self):
     app_cache.restore_window_size(self)
    def restore_cache_settings(self):
        app_cache.restore_window_size(self)
        if self.initial_mn_sel is None:
            mode = app_cache.get_value(CACHE_ITEM_UTXO_SOURCE_MODE, 2, int)
            if mode in (1, 2, 3):
                self.utxo_src_mode = mode

        # activated bip32 account numbers:
        nrs = app_cache.get_value(CACHE_ITEM_HW_ACCOUNT_NUMBERS, [0, 1, 2, 3, 4], list)
        nrs.sort()
        self.hw_account_numbers.clear()
        self.hw_account_numbers.extend(nrs)

        # base bip32 path:
        path = app_cache.get_value(CACHE_ITEM_HW_ACCOUNT_BASE_PATH.replace('%NETWORK%', self.app_config.gobyte_network),
                                   gobyte_utils.get_default_bip32_base_path(self.app_config.gobyte_network), str)
        if gobyte_utils.validate_bip32_path(path):
            self.hw_account_base_bip32_path = path
        else:
            self.hw_account_base_bip32_path = gobyte_utils.get_default_bip32_base_path(self.app_config.gobyte_network)

        # account number:
        nr = app_cache.get_value(CACHE_ITEM_HW_ACCOUNT_NUMBER, 0, int)
        if nr < 0:
            nr = 0
        self.hw_account_number = nr

        # bip32 path (utxo_src_mode 3)
        path = app_cache.get_value(CACHE_ITEM_HW_SRC_BIP32_PATH.replace('%NETWORK%', self.app_config.gobyte_network),
                                   gobyte_utils.get_default_bip32_path(self.app_config.gobyte_network), str)
        if gobyte_utils.validate_bip32_path(path):
            self.hw_src_bip32_path = path
        else:
            self.hw_src_bip32_path = gobyte_utils.get_default_bip32_path(self.app_config.gobyte_network)

        self.grid_column_widths = app_cache.get_value(CACHE_ITEM_COL_WIDTHS, self.table_model.getDefaultColWidths(),
                                                      list)

        sel_nasternode = app_cache.get_value(
            CACHE_ITEM_UTXO_SRC_MASTRNODE.replace('%NETWORK%', self.app_config.gobyte_network), '', str)
        if sel_nasternode:
            if sel_nasternode == '<ALL>':
                self.mn_src_index = len(self.masternodes)
            else:
                for idx, mn in enumerate(self.masternodes):
                    if mn.name == sel_nasternode:
                        self.mn_src_index = idx
                        break

        # restore last list of used addresses
        enc_json_str = app_cache.get_value(CACHE_ITEM_LAST_RECIPIENTS.replace('%NETWORK%', self.app_config.gobyte_network), None, str)
        if enc_json_str:
            try:
                # hw encryption key may be not available so use the generated key to not save addresses as plain text
                self.encryption_key = base64.urlsafe_b64encode(self.app_config.hw_generated_key)
                fernet = Fernet(self.encryption_key)
                enc_json_str = bytes(enc_json_str, 'ascii')
                json_str = fernet.decrypt(enc_json_str)
                json_str = json_str.decode('ascii')
                self.recipient_list_from_cache = simplejson.loads(json_str)
            except Exception:
                logging.exception('Cannot restore data from cache.')
 def restore_cache_settings(self):
     app_cache.restore_window_size(self)
     self.show_field_hinds = app_cache.get_value(
         CACHE_ITEM_SHOW_FIELD_HINTS, True, bool)