Beispiel #1
0
 def update_destination(self) -> None:
     text = ""
     if self._receive_key_id is not None:
         script_template = self._account.get_script_template_for_id(self._receive_key_id)
         if script_template is not None:
             text = script_template_to_string(script_template)
     self._receive_destination_e.setText(text)
Beispiel #2
0
 def show_qr(self) -> None:
     script_template = self._account.get_script_template_for_id(
         self._key_id)
     if script_template is not None:
         text = script_template_to_string(script_template)
         try:
             self._main_window.show_qrcode(text, 'Key script', parent=self)
         except Exception as e:
             self.show_message(str(e))
Beispiel #3
0
    def _get_request_URI(self, pr_id: int) -> str:
        with self._account.get_wallet().get_payment_request_table() as table:
            req = table.read_one(pr_id)
        message = self._account.get_keyinstance_label(req.keyinstance_id)
        script_template = self._account.get_script_template_for_id(req.keyinstance_id)
        address_text = script_template_to_string(script_template)

        URI = web.create_URI(address_text, req.value, message)
        URI += f"&time={req.date_created}"
        if req.expiration:
            URI += f"&exp={req.expiration}"
        return str(URI)
Beispiel #4
0
 def privkeys_thread():
     for keyinstance_id in keyinstance_ids:
         time.sleep(0.1)
         if done or cancelled:
             break
         privkey = account.export_private_key(keyinstance_id, password)
         script_template = account.get_script_template_for_id(keyinstance_id)
         script_text = script_template_to_string(script_template)
         private_keys[script_text] = privkey
         self.computing_privkeys_signal.emit()
     if not cancelled:
         self.computing_privkeys_signal.disconnect()
         self.show_privkeys_signal.emit()
Beispiel #5
0
    def _on_item_changed(self, item) -> None:
        if item is None:
            return
        if not item.isSelected():
            return
        pr_id = item.data(0, Qt.UserRole)
        with self._account._wallet.get_payment_request_table() as table:
            pr = table.read_one(pr_id)
        expires = age(pr.date_created + pr.expiration) if pr.expiration else _('Never')

        self._receive_view.set_receive_key_id(pr.keyinstance_id)
        script_template = self._account.get_script_template_for_id(pr.keyinstance_id)
        address_text = script_template_to_string(script_template)
        self._receive_view.set_form_contents(address_text, pr.value, pr.description, expires)
Beispiel #6
0
    def _update_receive_qr(self) -> None:
        if self._receive_key_id is None:
            return

        amount = self._receive_amount_e.get_amount()
        message = self._receive_message_e.text()
        self._save_request_button.setEnabled((amount is not None) or (message != ""))

        script_template = self._account.get_script_template_for_id(self._receive_key_id)
        address_text = script_template_to_string(script_template)

        uri = web.create_URI(address_text, amount, message)
        self._receive_qr.setData(uri)
        if self._qr_window and self._qr_window.isVisible():
            self._qr_window.set_content(self._receive_destination_e.text(), amount,
                                       message, uri)
Beispiel #7
0
    def on_update(self) -> None:
        if self._account_id is None:
            return

        # hide receive tab if no receive requests available
        b = len(self._account._payment_requests) > 0
        self.setVisible(b)
        self._main_window.receive_requests_label.setVisible(b)
        if not b:
            self._main_window.expires_label.hide()
            self._main_window.expires_combo.show()

        # update the receive address if necessary
        current_key_id = self._main_window.get_receive_key_id()
        if current_key_id is None:
            return

        keyinstance = None
        if self._account.is_deterministic():
            keyinstance = self._account.get_fresh_keys(RECEIVING_SUBPATH, 1)[0]
        if keyinstance is not None:
            self._main_window.set_receive_key(keyinstance)
        self._main_window.new_request_button.setEnabled(
            current_key_id != keyinstance.keyinstance_id)

        account_id = self._account.get_id()

        # clear the list and fill it again
        self.clear()
        for req in self._account.get_sorted_requests():
            date = format_time(req.date_created, _("Unknown"))
            amount_str = self._main_window.format_amount(
                req.value) if req.value else ""

            script_template = self._account.get_script_template_for_id(
                req.keyinstance_id)
            address_text = script_template_to_string(script_template)

            item = QTreeWidgetItem([
                date, address_text, '', req.description or "", amount_str,
                pr_tooltips.get(req.state, '')
            ])
            item.setData(0, Qt.UserRole, req.paymentrequest_id)
            if req.state != PaymentState.UNKNOWN:
                item.setIcon(6, read_QIcon(pr_icons.get(req.state)))
            self.addTopLevelItem(item)
Beispiel #8
0
    def item_changed(self, item):
        if item is None:
            return
        if not item.isSelected():
            return
        pr_id = item.data(0, Qt.UserRole)
        pr = self._account.get_payment_request(pr_id)
        expires = age(pr.date_created +
                      pr.expiration) if pr.expiration else _('Never')

        self._main_window._receive_key_id = pr.keyinstance_id
        script_template = self._account.get_script_template_for_id(
            pr.keyinstance_id)
        address_text = script_template_to_string(script_template)
        self._main_window.receive_destination_e.setText(address_text)
        self._main_window.receive_message_e.setText(pr.description or "")
        self._main_window.receive_amount_e.setAmount(pr.value)
        self._main_window.expires_combo.hide()
        self._main_window.expires_label.show()
        self._main_window.expires_label.setText(expires)
        self._main_window.new_request_button.setEnabled(True)
Beispiel #9
0
    def on_update(self) -> None:
        if self._account_id is None:
            return

        wallet = self._account._wallet
        with wallet.get_payment_request_table() as table:
            rows = table.read(self._account_id, flags=PaymentFlag.NONE,
                mask=PaymentFlag.ARCHIVED)

        # update the receive address if necessary
        current_key_id = self._receive_view.get_receive_key_id()
        if current_key_id is None:
            return

        keyinstance = None
        if self._account.is_deterministic():
            keyinstance = self._account.get_fresh_keys(RECEIVING_SUBPATH, 1)[0]
        if keyinstance is not None:
            self._receive_view.set_receive_key(keyinstance)
            self._receive_view.set_new_button_enabled(current_key_id != keyinstance.keyinstance_id)

        # clear the list and fill it again
        self.clear()
        for row in rows:
            date = format_time(row.date_created, _("Unknown"))
            amount_str = app_state.format_amount(row.value, whitespaces=True) if row.value else ""

            script_template = self._account.get_script_template_for_id(row.keyinstance_id)
            address_text = script_template_to_string(script_template)

            state = row.state & sum(pr_icons.keys())
            item = QTreeWidgetItem([date, address_text, '', row.description or "",
                amount_str, pr_tooltips.get(state,'')])
            item.setData(0, Qt.UserRole, row.paymentrequest_id)
            if state != PaymentFlag.UNKNOWN:
                icon_name = pr_icons.get(state)
                if icon_name is not None:
                    item.setIcon(6, read_QIcon(icon_name))
            item.setFont(4, self._monospace_font)
            self.addTopLevelItem(item)
Beispiel #10
0
 def update_key(self) -> None:
     script_template = self._account.get_script_template_for_id(
         self._key_id)
     if script_template is not None:
         text = script_template_to_string(script_template)
         self._key_edit.setText(text)