Пример #1
0
    def add_menu_items(self, menu: QMenu, account: AbstractAccount, main_window: ElectrumWindow) \
            -> None:
        menu.clear()

        # This expects a reference to the main window, not the weakref.
        account_id = account.get_id()

        menu.addAction(_("&Information"),
                       partial(self._show_account_information, account_id))
        seed_menu = menu.addAction(
            _("View &Secured Data"),
            partial(self._view_secured_data,
                    main_window=main_window,
                    account_id=account_id))
        seed_menu.setEnabled(self._can_view_secured_data(account))
        menu.addAction(_("&Rename"), partial(self._rename_account, account_id))
        menu.addSeparator()

        private_keys_menu = menu.addMenu(_("&Private keys"))
        import_menu = private_keys_menu.addAction(
            _("&Import"),
            partial(self._import_privkey,
                    main_window=main_window,
                    account_id=account_id))
        import_menu.setEnabled(account.can_import_privkey())
        export_menu = private_keys_menu.addAction(
            _("&Export"),
            partial(self._export_privkeys,
                    main_window=main_window,
                    account_id=account_id))
        export_menu.setEnabled(account.can_export())
        if account.can_import_address():
            menu.addAction(_("Import addresses"),
                           partial(self._import_addresses, account_id))

        menu.addSeparator()

        hist_menu = menu.addMenu(_("&History"))
        hist_menu.addAction("Export", main_window.export_history_dialog)

        labels_menu = menu.addMenu(_("&Labels"))
        action = labels_menu.addAction(
            _("&Import"), partial(self._on_menu_import_labels, account_id))
        labels_menu.addAction(_("&Export"),
                              partial(self._on_menu_export_labels, account_id))

        invoices_menu = menu.addMenu(_("Invoices"))
        self._import_invoices_action = invoices_menu.addAction(
            _("Import"), partial(self._on_menu_import_invoices, account_id))
        self._import_invoices_action.setEnabled(
            main_window.is_send_view_active())

        payments_menu = menu.addMenu(_("Payments"))
        ed_action = payments_menu.addAction(
            _("Export destinations"),
            partial(self._generate_destinations, account_id))
        keystore = account.get_keystore()
        ed_action.setEnabled(
            keystore is not None
            and keystore.type() != KeystoreType.IMPORTED_PRIVATE_KEY)
Пример #2
0
 def show_key(self, account: AbstractAccount, keyinstance_id: int) -> None:
     keystore = cast(KeepKey_KeyStore, account.get_keystore())
     client = self.get_client(keystore)
     derivation_path = account.get_derivation_path(keyinstance_id)
     assert derivation_path is not None
     subpath = '/'.join(str(x) for x in derivation_path)
     address_path = f"{keystore.derivation}/{subpath}"
     address_n = bip32_decompose_chain_string(address_path)
     script_type = self.types.SPENDADDRESS
     client.get_address(Net.KEEPKEY_DISPLAY_COIN_NAME, address_n,
                        True, script_type=script_type)
Пример #3
0
 def _add_account_to_list(self, account: AbstractAccount) -> None:
     account_id = account.get_id()
     item = QListWidgetItem()
     keystore = account.get_keystore()
     derivation_type = keystore.derivation_type if keystore is not None \
         else DerivationType.NONE
     is_watching_only = keystore.is_watching_only(
     ) if keystore is not None else True
     icon_state = "inactive" if is_watching_only else "active"
     if derivation_type == DerivationType.ELECTRUM_MULTISIG:
         tooltip_text = _("Multi-signature account")
         icon_filename = "icons8-group-task-80-blueui-{}.png"
     elif derivation_type == DerivationType.HARDWARE:
         tooltip_text = _("Hardware wallet account")
         icon_filename = "icons8-usb-2-80-blueui-{}.png"
     elif derivation_type == DerivationType.IMPORTED:
         # This should not be watch only as imported public keys have no keystore.
         tooltip_text = _("Imported private key account")
         icon_filename = "icons8-key-80-plus-blueui-{}.png"
     elif derivation_type == DerivationType.ELECTRUM_OLD:
         tooltip_text = _("Old-style Electrum account")
         icon_filename = "icons8-password-1-80-blueui-{}.png"
     elif derivation_type == DerivationType.BIP32:
         tooltip_text = _("BIP32 account")
         icon_filename = "icons8-grand-master-key-80-blueui-{}.png"
     else:
         # This should always be watch only as imported public keys have no keystore.
         tooltip_text = _("Imported public key account")
         icon_filename = "icons8-key-80-plus-blueui-{}.png"
     if is_watching_only:
         tooltip_text += f" ({_('watch only')})"
     item.setIcon(read_QIcon(icon_filename.format(icon_state)))
     item.setData(Qt.UserRole, account_id)
     item.setText(account.display_name())
     item.setToolTip(tooltip_text)
     self._selection_list.addItem(item)
     self._account_ids.append(account_id)
Пример #4
0
 def show_key(self, account: AbstractAccount, keyinstance_id: int) -> None:
     derivation_path = account.get_derivation_path(keyinstance_id)
     assert derivation_path is not None
     subpath = '/'.join(str(x) for x in derivation_path)
     keystore = cast(Ledger_KeyStore, account.get_keystore())
     keystore.show_address(subpath)