breezmobile icon indicating copy to clipboard operation
breezmobile copied to clipboard

Satscard Integration (Android & iOS)

Open PeteClubSeven opened this issue 5 months ago • 0 comments

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. 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 which other plugins in the app currently depend on however my plugin works with NDK 26+.

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/28~~ & https://github.com/breez/breez/pull/229. This PR supersedes https://github.com/breez/breezmobile/pull/1258

Here are a selection of images and videos demonstrating the implementation

Videos

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

iOS Differences

iOS handles NFC differently to Android, it requires a system prompt to be shown and you can't scan the Satscards in the background. As such a new option was added to the Receive option on the home page called "Sweep Satscard" and the NFC status is communicated to the use through the system prompt.

Note: There are some typos in these videos that have already been fixed.

https://github.com/breez/breezmobile/assets/130258664/f901aa06-3349-4029-8598-b928d7e5bb9e

https://github.com/breez/breezmobile/assets/130258664/1ae51ae8-2fba-44b1-9675-02624db9a9d5

Screenshots

PeteClubSeven avatar Jan 31 '24 22:01 PeteClubSeven