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( not account.is_watching_only() and not isinstance(account, MultisigAccount) \ and not account.is_hardware_wallet() \ and account.type() != AccountType.IMPORTED_PRIVATE_KEY) 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")) invoices_menu.addAction(_("Import"), partial(self._on_menu_import_invoices, account_id)) 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)
def _can_view_secured_data(self, account: AbstractAccount) -> None: return not account.is_watching_only() and not isinstance(account, MultisigAccount) \ and not account.is_hardware_wallet() \ and account.type() != AccountType.IMPORTED_PRIVATE_KEY