hsjoberg / lightning-box

A trust-minimized payment inbox for Lightning Addresses
MIT License
46 stars 6 forks source link

Attempt LNURL pay forwarding only if wallet supports it #7

Open lirre8 opened 1 year ago

lirre8 commented 1 year ago

Currently, if the wallet receiving an LNURL pay request is online but doesn't support forwarding lightning-box will time out after 30 seconds, in which case the senders wallet most likely has timed out already causing the payment to fail. In other words, it is only possible to send LNURL pay requests to wallets that doesn't support forwarding if the wallet is offline.

What do you think about adding a field on user level whether that user supports forwarding or not? And then only attempt forwarding if they do.

hsjoberg commented 1 year ago

Hi @lirre8, thank you for opening this issue. Indeed, the implementation is currently a bit sloppy. As a stop-gap fix, you can set the pubkey of the user to an empty string instead of the wallet pubkey. That way an attempt to forward the payment will never occur.

lirre8 commented 1 year ago

Ah right, didn't realize the pubkey was only used for the forwarding. I made this a bit more complicated fix that I'm running now: https://github.com/lirre8/lightning-box/commit/953a4d92ae6788202a91ada29a592ac3cfaceffb Not sure if that's anything how you want it to work?

It does allow the user to have a pubkey though, which brings me to my next idea: Is there any scenario where a withdrawal from the box should be allowed to a different pubkey than the one saved on the user? Or would it be a good to check that the destination pubkey always matches the user's pubkey: https://github.com/hsjoberg/lightning-box/blob/0276614b73276d82844cd09e5c053d270c933369/src/api/withdraw.ts#L121