NWC: a failed wallet payment drops the seller into the manual QR without saying why

Open
#955 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
dart, flutter

Research direction

Start with NwcPaymentWidget._pay in lib/shared/widgets/nwc_payment_widget.dart and trace onFallbackToManual to the screen that displays the manual QR. Read the invoice failure warning in NwcInvoiceWidget and check the existing localization and widget test patterns. Add a localized failure message for wallet errors and timeouts, then verify the relevant widget tests show the reason above the QR.

Written by the indexing model from the issue text.

Description

area: ui bug priority: medium

Context

When the seller presses "pay with wallet", NwcPaymentWidget._pay (lib/shared/widgets/nwc_payment_widget.dart:40-58) calls nwc_api.payInvoice. On any failure, whether a NIP-47 error from the wallet, a timeout or an exception, it calls onFallbackToManual, and the screen switches to the manual QR.

What happens

The reason is only printed (debugPrint('NWC payment failed: ${result.error}') / debugPrint('NWC payment error: $e')). The seller sees the screen change from a pay button to a QR with no message: nothing says the wallet refused, that it lacked balance, or that it never answered. "Insufficient balance", "the wallet is unreachable", "quota exceeded" and "restricted" all look the same, and none looks like an error. A user can easily believe the payment went through, or pay the QR from a second wallet without knowing why the first one failed.

The invoice side already does better: NwcInvoiceWidget shows a warning icon and a message when generation fails (line 109).

Mortsom's nwc_payment_refused_then_manual (INSUFFICIENT_BALANCE) and nwc_wallet_unreachable_then_manual (no answer) both pass. The fallback works, but the only evidence of why it happened is the harness's own wallet log.

How to fix

  1. Pass the failure to the screen: onFallbackToManual(String reason), or an enum built from the NIP-47 error code (INSUFFICIENT_BALANCE, QUOTA_EXCEEDED, RESTRICTED, PAYMENT_FAILED, timeout).
  2. When the screen switches to manual, show it as a localized banner above the QR, or as a snackbar, e.g. "Your wallet could not pay: insufficient balance. Pay this invoice from another wallet or cancel the trade."
  3. Optional, and a contract change: expose the reason on an automation readout (e.g. pay.nwc.error, labelled with the code), so automation can assert the right failure was reported.
  4. Add widget tests for each mapped code and for the timeout.
Dominant language
Dart
Stars
11
Forks
9
Avg merge
2d 1h
Merged PRs (30d)
16

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MostroP2P/app

All issues in MostroP2P/app

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.