usawa

Signed, immutable accounting.
Log | Files | Refs | Submodules | LICENSE

commit 6c9a15e011660f7abdc877fd1ddeaf9544db4c98
parent a386e880a6e721d7678a32466e0c789e476392a7
Author: Carlosokumu <carlosokumu254@gmail.com>
Date:   Wed, 18 Mar 2026 12:36:31 +0300

pass passphrases from the GUI

Diffstat:
Mdummy/usawa/gui/components/passphrase_dialog.py | 6+++---
Mdummy/usawa/gui/components/wallet_setup.py | 27+++++++++++++++++++++++----
Mdummy/usawa/gui/main_window.py | 7++++---
3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/dummy/usawa/gui/components/passphrase_dialog.py b/dummy/usawa/gui/components/passphrase_dialog.py @@ -124,18 +124,18 @@ class PassphraseDialog(Adw.Dialog): wallet_class=self.wallet_class, passphrase=passphrase, ) - GLib.idle_add(self._unlock_success, wallet) + GLib.idle_add(self._unlock_success, wallet, passphrase) except Exception as e: logg.warning("Passphrase unlock failed: %s", e) GLib.idle_add(self._unlock_failure, str(e)) - def _unlock_success(self, wallet): + def _unlock_success(self, wallet, passphrase): logg.info("Wallet unlocked successfully") self._set_loading(False) self._unlocked = True self.force_close() if self.on_success: - self.on_success(wallet) + self.on_success(wallet, passphrase) def _unlock_failure(self, error_msg): self._set_loading(False) diff --git a/dummy/usawa/gui/components/wallet_setup.py b/dummy/usawa/gui/components/wallet_setup.py @@ -62,6 +62,13 @@ class ImportWalletDialog(Adw.Dialog): self.spinner = Gtk.Spinner() box.append(self.spinner) + self.error_label = Gtk.Label(label="") + self.error_label.set_css_classes(["error"]) + self.error_label.set_visible(False) + self.error_label.set_wrap(True) + self.error_label.set_justify(Gtk.Justification.CENTER) + box.append(self.error_label) + button_row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8) button_row.set_halign(Gtk.Align.CENTER) box.append(button_row) @@ -148,12 +155,24 @@ class ImportWalletDialog(Adw.Dialog): self.parent.toast_overlay.add_toast(toast) self.close() StateManager.set("wallet_path", self.privatekey_path) - self.parent._init_with_wallet(wallet) + self.parent._init_with_wallet(wallet, self.passphrase) def _on_error(self): self.spinner.stop() self.import_btn.set_sensitive(True) self.browse_btn.set_sensitive(True) - toast = Adw.Toast.new("Failed to decrypt wallet — check your GPG setup") - toast.set_timeout(5) - self.parent.toast_overlay.add_toast(toast) + self._show_error("Wrong passphrase or invalid wallet file.") + self._shake_entry() + + def _show_error(self, message: str): + self.error_label.set_label(message) + self.error_label.set_visible(True) + + def _shake_entry(self): + self.passphrase_row.add_css_class("shake") + + def remove_shake(): + self.passphrase_row.remove_css_class("shake") + return False + + GLib.timeout_add(400, remove_shake) diff --git a/dummy/usawa/gui/main_window.py b/dummy/usawa/gui/main_window.py @@ -141,15 +141,16 @@ class UsawaMainWindow(Adw.ApplicationWindow): dialog = PassphraseDialog( store=store, wallet_class=UsawaWallet, - on_success=lambda wallet: self._init_with_wallet(wallet, False), + on_success=lambda wallet, passphrase: self._init_with_wallet( + wallet, passphrase, False + ), on_cancel=self._on_wallet_cancelled, ) dialog.present(self) - def _init_with_wallet(self, wallet, save_wallet: bool = True): + def _init_with_wallet(self, wallet, passphrase, save_wallet: bool = True): """Called after wallet is successfully imported.""" self.wallet = wallet - passphrase = self.cfg.get("WALLET_KEY_PASSPHRASE") repository = LedgerRepository( ledger_path=self.ledger_path,