NWC: the wallet balance is read once at connect and never refreshed

Aperta
#956 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
dart, flutter

Direzione di ricerca

Start with lib/features/settings/providers/nwc_provider.dart and the Rust bridge at lib/src/rust/api/nwc.dart; trace connectWallet, payInvoice, trade success, wallet screen opening, and app resume to find the refresh points. Treat failed refreshes as unknown without displaying zero. Add the provider and widget tests described in the issue; done means the wallet screen shows the updated balance after each refresh trigger and the tests pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: ui bug priority: low

Context

NwcNotifier keeps balanceSats in NwcWalletState, and the connected wallet screen shows it (nwcBalanceSats). It has an updateBalance(int? sats) method "from a get_balance result" (lib/features/settings/providers/nwc_provider.dart:66), and the Rust bridge exposes getBalance() (lib/src/rust/api/nwc.dart:37).

What happens

Nothing calls updateBalance, and nothing calls getBalance(). The balance shown is the one read once in connectWallet (at connect, or when reconnecting at startup). After the wallet pays a hold invoice, or receives a payout from a make_invoice it generated, the settings screen keeps showing the old balance until the app restarts. That figure can be off by the whole trade amount, and the user may decide whether to pay with the wallet based on it.

How to fix

  1. Refresh the balance (getBalance() → updateBalance) when the wallet screen opens, after a successful payInvoice, after a trade where the wallet generated the payout invoice reaches success, and on app resume.
  2. Treat a failed refresh as "unknown" (keep the last value and mark it stale, or hide it). Don't show 0.
  3. Add a provider test: after updateBalance is wired to a fake getBalance, the state changes. Add a widget test that the wallet screen shows the refreshed figure.
Lingua principale
Dart
Stelle
11
Fork
9
Merge medio
2g 1h
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MostroP2P/app

Tutte le issue di MostroP2P/app

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.