litecoin-foundation / litewallet-android

Litewallet Android
MIT License
32 stars 12 forks source link

🥳[Feature] Add bech32 to enable ltc1 addresses & false positive rate (Bloom Filter) interface #137

Closed kcw-grunt closed 1 year ago

kcw-grunt commented 1 year ago

Overview

What can I say. This has been a beast. This PR is not of the faint of heart!

The goal was to add this feature to the Android client to allow users to send to ltc1 addresses. This has been a long-requested feature for literally years. Why years? We haven't had a strong Android / C dev to tackle the original critical bug. When Android accesses the database with the bech32 structure users addresses and their database would be borked/disappear.

Litewallet users losing all of their Litecoin would be really bad.

We also migrated the Android OS window which alleviated the issue. This was the first year where the older Android versions were so minimal it was much safer.

Caution!

The first step was to give users a way to access their seed which was never part of the original code. This meant at the worst case they could restore the wallet elsewhere. This was added (Yay!)

Tested v2.8.3 (727)
small-show-seed

Merging Bech32 Issues

When the bech32 files / branch from loafwallet-core was used, the code worked and the version was submitted for beta testing (v2.8.3 (729) Bech32 + Show Seed) March 15.

It was a serious flop.

The question was : "Why so few people were testing/using this version?" It turns out the the sync time (all users must sync with the new bech32 database) was hideous.
It was clocked at 77 mins. This version never got more than 1% of testers to download.

It turned out that the sync was heavily affected by the default settings of the Bloom Filter false positive rate. There was no way to let the user adjust it.

Giving users a choice

Adding options for the false positive rate meant that users could shorten their sync time albeit at a reduced anonymity. With changing the fp Rate users essentially give a list of their Litewallet addresses and so it was effectively spotlighting the user. With a high fpRate, users are now sending many spurious LTC addresses with their addresses and the node will simply verify. The down side is the sync time would be lengthened.

This feature was added!🍔

Add user preference False Positives
sync-preferences-clip

Now what?

We are not done. While the sync was different, here were cases where the sync reset many times. This is where the code is now in draft

kcw-grunt commented 1 year ago

Nice feature! @kcw-grunt I see Timbers. Is timber like logging messages?

Yep that's correct @josikie !

Check out https://github.com/JakeWharton/timber. I'm not sure if we will use it in Newborn but it is a nice to know if you want to be an Android developer.

josikie commented 1 year ago

Wow, thank you! @kcw-grunt

kcw-grunt commented 1 year ago

Added a warning message / snackbar so people know they will need to sync:

IMPORTANT Message
snackbar-sync