Adding support for lightning addresses within contacts #640
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for lightning addresses within the Contacts functionality.
For existing contacts, the UI looks nearly identical:
But it now allows for multiple offers to be added, and multiple lightning addresses too:
When you add/edit an offer, you're now able to (optionally) provide a label:
This is quite helpful because, if a user does have multiple offers, they're probably for different wallets, or different services (in the case of a business). So the label is quite necessary.
Tapping the 3-line button provides a menu with various options:
Technical notes:
There's a new database table called
contact_addresses
, which basically uses the same layout as the existingcontact_offers
.When you fetch a
ContactInfo
, it now looks like this:These functions are gone, and in their place is a single function that does everything for you:
Note that even though this function is helpful, the UI cannot call it blindly. We don't support duplicate offers within the system. That is, you can't add offer X to contact Bob if offer X is already associated with contact Alice. Attempting to do so will throw a sqlite error. And the same restriction applies to duplicated addresses. So the UI is responsible for checking, and displaying the proper error message to the user.
contactsList: StateFlow<List<ContactInfo>>
), there are a bunch of (non-suspending) functions to fetch the ContactInfo given a:This means you can replace the call to
suspend fun getContactForOffer(offer: OfferTypes.Offer)
withfun contactForOffer(offer: OfferTypes.Offer)
Todo:
Motivation:
Not a lot of wallets support Bolt12 offers yet. Even less support receiving a payment via their own offer. Which means our Contacts functionality is basically limited to just Phoenix users right now.
Additionally, many people will simply prefer lightning addresses. They're a familiar format. And they're human-readable, and human-writable, and human-speakable. And they're modifiable (i.e. If I own/control the address, I can point it at a new wallet. Which gives me wallet independence.)
So this is a nice increase in the functionality of our Contacts feature.