alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

Is there a way to include metadata hash in createInvoice? #148

Closed FilipChalupa closed 2 years ago

FilipChalupa commented 2 years ago

I'm implementing LNURL service but can't get over the h tag requirement. https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md#requirements-3 The h tag is then required by a wallet. https://github.com/fiatjaf/lnurl-rfc/blob/luds/06.md#notes-on-metadata-for-server-side-lnurl-pay

Please is there a way to include metadata hash in an invoice using ln-service or am I trying to do something which is not yet possible?

alexbosworth commented 2 years ago

I think there are security concerns or something, I don't know

FilipChalupa commented 2 years ago

I don't doubt that.

I will investigate then. I hope I am on the right track looking into alexbosworth/lightning/lnd_methods/invoices/create_invoice.js.

FilipChalupa commented 2 years ago

By diving deep into the lnd I've found out that the answer was right under my nose. The h tag is sometimes called description_hash which is supported by ln-service. 🎉

basharov commented 2 years ago

By diving deep into the lnd I've found out that the answer was right under my nose. The h tag is sometimes called description_hash which is supported by ln-service. 🎉

Can you please share some code that could help us understand how you create a lnurl-pay flow if possible? Thanks!

alexbosworth commented 2 years ago

you could look here https://github.com/alexbosworth/balanceofsatoshis/blob/master/lnurl/pay.js

basharov commented 2 years ago

@alexbosworth My problem is I'm trying to build a flow for lnurl pay but stuck with description_hash.

Spec says it's sha256 of description or meta, but seems like I'm misunderstanding what value it should have exactly.

I asked on SO https://stackoverflow.com/questions/72366005/how-to-get-a-specific-hash-value-from-a-specific-string, and seemed like I got some clue but still not much luck.

When I try the flow via a mobile wallet like breez or BlueWallet, in most cases it shows "description has not found in invoice"

image

image

image

When I decode the invoice with some online tools, I indeed don't see h in raw value and no description_hash in parsed one.

I tried to pass all kinds of data via sha256 utils, bech32 lib, converting from this to that and vice versa.

Can you advise in what direction I should move?

By the way I managed to implement lnurl withdraw flow and it works in the wallets I use.

alexbosworth commented 2 years ago

I'm not sure if I have an example for that other than the linked lnurl methods