-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LUD-18 Service Support #518
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels weird not doing anything with the payer data, but I guess that's not really part of the spec. Just hashing it into the invoice, if provided. Let me know what you think!
@@ -62,17 +66,15 @@ module.exports = withPlausibleProxy()({ | |||
{ | |||
source: '/.well-known/:slug*', | |||
headers: [ | |||
...corsHeaders | |||
...corsHeaders, | |||
noCacheHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set no caching here since we include a k1
in the response payload that's unique for each request.
@@ -83,7 +85,8 @@ module.exports = withPlausibleProxy()({ | |||
{ | |||
source: '/api/lnurlp/:slug*', | |||
headers: [ | |||
...corsHeaders | |||
...corsHeaders, | |||
noCacheHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
pages/api/lnurlp/[username]/index.js
Outdated
k1Cache.set(k1, username) | ||
// Invalidate the k1 after 10 minutes, if unused | ||
setTimeout(() => { | ||
k1Cache.delete(k1) | ||
}, 1000 * 60 * 10) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with an in-memory cache because it felt like overkill to store this in the DB. However, I am not certain of SN's deployment architecture (i.e. are there several server instances behind a load balancer?), so if we need to push the k1 cache to the DB to share across instances, I can make those changes. Just let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we have serveral servers behind a load balancer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll move it to the DB, then. Thank you for the confirmation.
Is the intent to extend this to do more? Because I agree. I'm not sure we're gaining anything here yet |
I didn't have any specific plans. I think what we gain with this is spec compliance, so the question may really be, what does the spec give us? My understanding is that there's value is hashing payer identifying data into the invoice so that you can provide proof of payment, should you need to (meaning, alice payed this invoice, not bob). We could store the payer data as a string in the invoice table and show it to the payee on the invoice instance page, tucked in an accordion or something. But I'm not sure we should, because I'm not sure wallets indicate whether this information is exposed to the payee like they do with LUD-12 comments. See Open Bitcoin Wallet for an example of this, I found this on DarthCoin's substack. Alby doesn't seem to make this distinction in their UX, so it's hard to say... |
I could see this being more useful in the other direction: when someone goes to pay SN, we give them a photo and stats and stuff so they can verify it's going to the right place ... or when someone is paying out of SN, we give them a photo and stuff about the person they're sending to. |
I need to think about this some more, but this sounds more like recipient (of the sats) validation vs sender (of the sats) validation, which, AFAICT, isn't really what LUD-18 is about? I might just need to re-read the above a few times for it to click... |
Yeah it's probably another spec item. |
Here you can test LUD-18 very nice. |
Thank you Darth, that is a neat place to experiment. I used Alby to send and I can see my LUD-12 message (comment) and also the name I sent along (LUD-18). So from the SN perspective, perhaps we could store the identification info in our invoice DB, and extract any human-readable identification methods and include those in invoice notifications and listings? I was just concerned about privacy, exposing payer data to the payee, but I guess that's the point? Let me know what you think, @huumn , I can update the PR to reflect those changes to make this more useful! |
Privacy was my concern as well, but if the payer is opting in I guess it's what they want.
Let's do it |
@SatsAllDay So I think for stacker.news, it could be nice to have the payerdata visible in the transaction log, as you guys have already talked about. Specifically, Another neat thing would being a consumer of LUD-18. As @Darth-Coin mentioned, supporting LUD-18
@huumn If I understand you correctly, these things can be provided by the normal LUD-06 LNURL-pay protocol. |
@hsjoberg you rock! |
LNURL Mafia Boss is here! |
👍
Yea, that would be a good enhancement. You're correct that this PR is really just covering the |
* don't cache the well-known response, since it includes randomly generated single use values * validate k1 from well-known response to pay URL * only keep k1's for 10 minutes if they go unused * fix validation logic to make auth object optional
* move k1 cache to database * store payer data in invoice db table * show payer data in invoices on satistics page * show comments and payer data on invoice page
…on, wallet history
I think this is ready for review now. I would like to do the wallet side in a separate PR, based on the above discussion. |
For those following along, I've worked up the LUD-18 wallet implementation in #531 |
What's the purpose of our use of the challenge I guess we could eventually use it to auth the sender but without a way to verify with the wallet couldn't they still send arbitrary payer data? Is there another LUD that would help us ask the wallet if the payer data is legit? |
It's used here to validate the supplied signature. It is only used if you supply the
AFAIK any payer data aside from |
I believe it's ownership of a linking key (which is derived from an arbitrary pubkey but is irreversibly hidden from us when generating the linking key) and cannot be independently verified. Just trying to figure out if we should use auth if we can't really use it to authenticate payer data. |
Yes I think you are right. We certainly could remove auth for now and reconsider including it later on. It would considerably simplify things in this PR. I have yet to encounter another service that supports it. I added it because it was in the spec ¯\_(ツ)_/¯ |
I'm going to work on removing it fyi. I already have it going locally. |
Nice work! Other than removing auth, the only other significant change was using changing the payer data to be stored as JSONB. I regretted not doing this for nostr zaps. |
Awesome, thanks! |
This PR implements LUD-181, namely incorporating payer data in payRequest invoices.
I have made all identification methods optional (
mandatory: false
), this can change over time if needed.Footnotes
LUD-18 Spec ↩