damus-io / damus

iOS nostr client
GNU General Public License v3.0
1.99k stars 288 forks source link

LN payment flow hardening #1892

Open danieldaquino opened 8 months ago

danieldaquino commented 8 months ago

This is a placeholder task for further improvements/hardening of the LN payment flow.

Continuation of https://github.com/damus-io/damus/issues/1754 and https://github.com/damus-io/damus/issues/1827

Acceptance criteria

Note: This ticket is generic, it can be split into more tickets if convenient.

danieldaquino commented 7 months ago

@jb55, since the recent damus-api changes might still be fresh in your mind, what do you think of the acceptance criteria here? Any other suggestions on things we can do to improve robustness?

To save you a trip to Github, I will list them here so you can stay in your email client lol:

  • Add unit tests to damus-api that covers the LN flow as well as edge cases
  • Add support@damus.io email on purple website and checkout
  • Lightning flow: Better integrate lightning expiry into the code as a mechanism to prevent stale/unmonitored invoices and improve robustness
  • Make sure expiry bumping logic handles edge cases
  • Save checkout objects into lmdb for better crash resistance
  • Add more timestamps and data to the DBs, as well as server logs to help us diagnose problems and manually fix things in case issues arise
  • LN flow: Handle edge cases better (e.g. How does the UI display an expired invoice? How does the UI handle when the server is having issues? Does it displays errors nicely?)
  • Add more guidance messages on the UI for certain edge cases (e.g. What if the user is running an incompatible version of Damus and the Verify npub link does not work? There should be some message in the website mentioning that if the link fails they might need to update the app)
  • Better safeguards against unauthorized use of damus:purple links
danieldaquino commented 7 months ago

Save checkout objects into a DB for better crash resistance

Patch sent: https://groups.google.com/a/damus.io/g/patches/c/eT2BINfOH0Q

danieldaquino commented 7 months ago

@jb55, @alltheseas, I wrote some code to better handle checkout errors (if they occur)

I went on each function, each step of the checkout process, and added error handlers with a detailed message.

Here is one example:

Screenshot 2024-01-30 at 17 09 02

danieldaquino commented 7 months ago

@jb55, don't know if this is the right ticket to send this, but here is a preview of the discount label I just wrote (I did not send this patch yet)

Screenshot 2024-01-30 at 18 17 44

alltheseas commented 7 months ago

Figure out which are critical items

alltheseas commented 7 months ago

What should expiry invoice duration be? @danieldaquino suggests short invoice, so LN node does not have to keep checking status for invoices.

Core LN default is one (1) week.

There remains one unsolved checkout/subscription request.

danieldaquino commented 6 months ago

On iOS, make "Verify Npub" screen raise a session flag indicating that a checkout is in progress, and detect if account was created when app enters foreground, to show welcome sheet right away

Moved this to https://github.com/damus-io/damus/issues/2021