breez / breezmobile

Lightning Network mobile client
https://breez.technology
GNU General Public License v3.0
567 stars 130 forks source link

Satscard Integration (Android) #1258

Closed PeteClubSeven closed 7 months ago

PeteClubSeven commented 9 months ago

Hey, this is my implementation of Satscard slot initialization and sweeping. The logic for communicating with Satscards is handled by a separate Flutter plugin which I created. This plugin is relatively simple, it provides an FFI wrapper around Nunchuk's tap-protocol library. Maintenance should be minimal, I created a separate release/breez branch in the plugin repository, this will get updated as Nunchuk update their C++ library. I will do further work myself to support the Tapsigner however this won't be relevant for Breez which is why I created a release branch. You may wish to fork my plugin if you prefer control over the repository, I could then open PRs when I think there's a bugfix you might need. My plugin is built for NDK 21.4, it could work with NDK 22 but NDK 23+ and onwards are incompatible for now until a tap-protocol change. I tested almost exclusively with NDK 21.4 but it seems like NDK 19 (the version used by Breez) does compile. However it seems theres some plugins in the app that require NDK 21.4. What would be preferable?

This PR doesn't support viewing/sweeping unsealed slots however I wish to add that later and the current balance/sweep UI pages are built to support it already. Each UI page supports vertical scrolling for small displays. The initialize page has fully validated "Spend Code" and "Chain Code" fields. The new Satscard NFC dialog is quite reactive and communicates different success, pending and failure states to the user. Sweeping a Satscard clearly communicates the fees paid by the user including failure conditions such as not having enough balance to deposit, having too high a balance, not meeting the reserve, etc. The "Spend Code" field rejects previously entered incorrect codes, intentionally I chose not to persist these between pages. If a "Chain Code" is not entered then it will be generated by the tap-protocol library.

The PR depends these two other PRs: https://github.com/breez/Breez-Translations/pull/26 & https://github.com/breez/breez/pull/229

Here are a selection of images and videos demonstrating the implementation:

https://github.com/breez/breezmobile/assets/130258664/1e12c0b7-7966-4d70-afa4-aad582d95bf0

https://github.com/breez/breezmobile/assets/130258664/f6e99c56-e841-4a84-9df7-03643a200561

https://github.com/breez/breezmobile/assets/130258664/5f2b86f3-0c4c-4e61-99f1-2afba38985ca