ACINQ / phoenix

Phoenix is a self-custodial Bitcoin wallet using Lightning to send/receive payments.
https://phoenix.acinq.co
Apache License 2.0
644 stars 97 forks source link

LNURL Lightning Address Support 'text/identifier' field #211

Closed juscamarena closed 2 years ago

juscamarena commented 2 years ago

text/identifier is an optional metadata field used with a lightning address.

It seems Phoenix errors if there are any metadata types that are not known to Phoenix, it also errors if nothing is set and it's an empty array.

Here's the documentation.

https://github.com/fiatjaf/lnurl-rfc/blob/luds/16.md

Here's the error logs from phoenix:

2021-10-18 11:48:37,760 INFO f.a.p.lnurl.LNUrl$Util - retrieving metadata from LNURL=https://bitrefill.me/.well-known/lnurlp/max 2021-10-18 11:48:38,982 WARN f.a.p.lnurl.LNUrl$Util - could not process raw meta=["text\/identifier","max@bitrefill.me"] at index=0: unhandled metadata type=text/identifier 2021-10-18 11:48:38,991 ERROR f.a.p.lnurl.LNUrl$Util - could not read raw meta=[["text/identifier","max@bitrefill.me"]]: java.lang.NullPointerException: null at fr.acinq.phoenix.lnurl.LNUrl$Util.buildLNUrlPayMeta(LNUrl.kt:193) at fr.acinq.phoenix.lnurl.LNUrl$Util.extractLNUrl(LNUrl.kt:131) at fr.acinq.phoenix.utils.Wallet.parseLNObject(Wallet.kt:143) at fr.acinq.phoenix.send.ReadInputViewModel$readInput$1$1.invokeSuspend(ReadInputViewModel.kt:73) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) 2021-10-18 11:48:38,992 INFO f.a.p.s.ReadInputViewModel - invalid lightning object:

dpad85 commented 2 years ago

Thanks for reporting this, I'll look into it.

juscamarena commented 2 years ago

I've removed the metadata field now so it'll work with us, but I think other services use it, not sure.

dpad85 commented 2 years ago

There's no issue on Phoenix's side at least in the example you gave: the full metadata provided by the bitrefill.me service was [["text/identifier","max@bitrefill.me"]], which violates the LUD-06 specs (because it does not contain the mandatory "text/plain" metadata). Phoenix will also error if the metadata array is empty, that's due to that same spec constraint.

The log of Phoenix you attached is not very explicit and a bit scary, but it actually means that "text/plain" is missing.

You can add the text/identifier metadata field back and it should work as long as the text/plain field is there. The identifier field will just be ignored (there will be a warning in the logs), but the app won't error. Please reopen this issue if that's not the case.