pull down to refresh
@hampus Taking a look at chat.blixtwallet.com's code, I don't see any explicit decoding of the query param: https://github.com/hsjoberg/lnurl-pay-chat-server/commit/a28f998675a675a835ea1a639be2ec1f1fdae0ec#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80L226
Perhaps we're double encoding when we shouldn't be?
Perhaps we're double encoding when we shouldn't be?
Yes, as far as I can tell, it seems to be double-encoded when it shouldn't be.
A quick look.
Yours require two decodeURIComponents:
// stacker.news
decodeURIComponent(decodeURIComponent("%257B%2522identifier%2522%253A%2522SatsAllDay%2540stacker.news%2522%257D"));
'{"identifier":"SatsAllDay@stacker.news"}'
// blixt wallet
decodeURIComponent("%7B%22name%22%3A%22Hampus%22%2C%22identifier%22%3A%22hampus%40blixtwallet.com%22%7D");
'{"name":"Hampus","identifier":"hampus@blixtwallet.com"}'Though I'm not sure who's in the wrong here. I'll investigate some more.
We’re probably getting URI encoding for free with the native JS API that constructs the URL
I don't see any explicit decoding of the query param:
It was some time ago I made this server, but I think Fastify is implicitly decoding the GET params. It makes it into an object.
It will naturally not attempt to decode twice, which is why the JSON.parse() errors out.
Perhaps we're double encoding when we shouldn't be?
Yes, my understanding after reading the specification again is that it should not be encoded twice.
Yea that makes sense. I’ll work up a fix today!
Great! Cheers.
@hampus I see this in the logs when trying to call the invoice request from my dev machine:
{ statusCode: 500, error: 'Internal Server Error', message: 'Could not parse query params' }with a query param string of
?amount=10000&payerdata=%257B%2522identifier%2522%253A%2522SatsAllDay%2540stacker.news%2522%257DAn issue decoding the URI encoded param, maybe?
ETA: same thing when you send
name, as well. Are we doing thepayerdataquery param encoding incorrectly?