phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Support fiat offers

Open dpad85 opened this issue 2 months ago • 0 comments

Bolt12 offers may specify an amount, and that amount may be in a fiat currency. The wallet should be able to understand that, and convert the amount to btc, using the feerate fetched by the CurrencyManager.

Conversion can be done using the method FiatCurrency.valueOfOrNull(offer.currency), since offer.currency is the standard currency code.

A new method fetchRateForCurrency has been added in CurrencyManager. It immediately fetches the feerate of a given fiat currency and refreshes the cache ; or will return the cached value is the cache is fresh.

Since the conversion is not accurate, the user should be able to change the amount to send, even use an amount below what Phoenix computed. The recipient may then reject the payment if it's too far from what he actually expects for the given fiat amount.

This PR depends on : https://github.com/ACINQ/lightning-kmp/pull/804

Example offers:

1 euro
-----
lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqxqdz425sgqyqs5rp3ypjh2un0yphkven9wggwuqun8zz24uwkkyyrjlj7lewgd08jmr9g6tmspmdfnkujzn7zwy43xsp8te5em74wwg0c4ccz0mcpgj0xqgefpvtj7q7mh3jlft208vluddqzqdc8gwx494a57zmp24zuv3c8ydu36jl2hvu5skxk2ugyxmu8ldzdcqpng62kpmcznwkgfmk9443mde6nr8d5x4g9jvl0zxm7ez45xzx6gqwtpag4q749qua5wtn69w8xgy622cc9hcp9mnkq4hveyrnjj96v7crgnmjrzwyjdjw5nustdvwfe7kf6pws33sqxt4plja8th557v6txa0yknvls6ax29mylt8lcmlm3xam8wwnnyc5euf9v9fquqc260fu3lnn0fyf9rxjlq

1234 euros
-----
lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqxqdz425sgqgzdyzssxyerxdpqv46hymmnyphkven9wggwuqun8zz24uwkkyyrjlj7lewgd08jmr9g6tmspmdfnkujzn7zwy43xspsetzx8mclv6xxccuut5ep7fvkvxnp9zg5pqwsv2nhd33fjhapysqzqgja0nxwjphl5yu6qrzxky82f64gjdlt5jvnyzr9zu2254q2g78mkqpnkw5dzavwdy68rwfejmz04ed5e56zfxxf82yzqqtukyjmj6dcx9jluh62z6zpz029lxetddqayk4mmz4xyypkxph8s3mnn7x3jece5kvejrhy7qxlnelg7qt6c8tua6tcekmsh5sqxfg2deugn4ycashz95yvfz2nl3094qql2pt9lt0ude9nsvgmsugfenw2xsu43ymrktnfr69s8f97czwtay

Screenshots:

The UI is almost unchanged, except for a label below the amount input mentioning that the invoice is labelled in fiat:

image

Tapping on the "Invoice requests 1 EUR" message, the app displays a modal with some details:

image image

dpad85 avatar Oct 06 '25 16:10 dpad85