pull down to refresh

More experienced users know, that nowadays you can send satoshis directly to Lightning Address in user@domain format. But how exactly does this work?
In this short article I would like to explain it to those who do not know it. At the same time, I will describe the basics of Lightning invoices and LNURL-pay protocol.

Lightning invoices basics

Lightning Invoices are nowadays the standard for sending and receiving funds on the Lightning Network. If you want to receive some satoshis, you have to generate an invoice on your node/wallet. An invoice is nothing more than a text string (which starts with lnbc...) and contains, among other things, the recipient ID and the amount. There is actually more information but we won't go into that now. The invoice is most often shared using a QR code, which is nothing more than an image representation of the string described earlier.
Lightning wallet then builds up several paths in the network to the recipient, ranks them from most advantageous and tries one by one until the payment is successful (or sometimes not).
However, Lightning invoices have certain limitations. Imagine you're a YouTuber and you want to embed a static QR code in your videos so your fans can send you donations. Each invoice has a expiration limit (usually 1 hour) and cannot be paid more than once. This is because some nodes learn a random number called payment_preimage when routing a payment, so it is not safe to pay one invoice multiple times, as fraud could occur. What to do about it? Let's use LNURL-pay!

LNURL-pay basics

LNURL-pay is a standard, that allows us to create a static QR code, that can be paid multiple times. How does it work?
At its core, it is nothing more than a URL link to a web service using the HTTPS protocol (alternatively Tor), which is encrypted using bech32 encoding. A huge advantage in terms of user-friendliness is the fact that QR codes are indistinguishable to the human eye and therefore the average user does not need to know whether they are paying a regular invoice or LNURL-pay.
Payment procedure:
  1. User scans the QR code (LNURL-pay) using his Lightning wallet.
  2. Wallet decodes the QR code, then decodes the bech32 string, gets the URL and visits it using HTTPS.
  3. Service responds to the wallet with a message asking for the amount (can be fixed).
  4. User fills in the amount and sends this information to the service.
  5. Service will return a classic Lightning invoice for the amount selected by the user.
  6. Wallet will pay the invoice.
And that's it! So LNURL-pay is just a protocol that is used to negotiate (via the web server) what amount I want to generate an invoice for.

Finally - Lightning Address

Now that we know the principles of invoices and LNURL-pay, understanding Lightning Address will be very easy. Remember, how we need to scan a QR code with LNURL-pay to get an initial HTTPS link?
With Lightning Address, you don't have to scan any QR code. For example, if your address is heisenberg@stacker.news, your wallet will translate that into URL https://stacker.news/.well-known/lnurlp/heisenberg. In other words, the link is not obtained from the QR code but is "compiled" from the Lightning Address. Your wallet visits this URL and the answer is well known LNURL-pay request, how much do you want to pay (point 3 above). Then the procedure is identical. And that's it!

How to use it?

Many custodial wallet/solution nowadays generates a Lightning Address for you automatically, for example every user has address in format username@stacker.news. If you want to pay something to this address, just insert the address to the "invoice field" in your Lightning wallet. It's supported by majority of wallets. Another solution is to use tools hosted on your own Lightning node (like LNBits, LnMe or others) to be able to receive satoshis non-custodially.
I hope you learned something new and let me know if you would be interested in similar articles.
THIS is the content we should have every day on SN! Not the posts about shitcoins.
reply
I love how you always end up posting about shitcoins.
reply
reply
so you don't like shitcoins? lol, yes I agree with you, I like learning and I learned something through this post
reply
Is not about me if I like or not shitcoins. That's not important. Is about that shitcoins are a disease to this world as is the fiat money.

Shitcoining is sin. No matter form or shape you touch it. So stay away from them.

Maybe in time you will understand that, but I am in this Bitcoinlandia for long time and I've seen a lot of shit going on.
reply
Is gold a shitcoin?
reply
reply
Gold is a metal not a shitcoin
Currency based on gold are kinda shitcoins. I think its important to make the distinction. A currency backed by bitcoin would also be a shitcoin imo. Sorry just my 50 shitcoins
reply
Yes, you are right, we have to make the distinction. But we are not living in a non-digital era now... so gold became just a metal used in industrial stuff and not being used to back fictional currencies.
If we were living in a non-digital era, yes, gold will still be the king. Now, his time is over. So became a shitcoin.
reply
It's not about whether or not I like shitcoins. That's not important. It's that shitcoins are a disease to this world as is fiat money.
Shitcoining is a sin. No matter what form or shape you touch it. So stay away from them.
Maybe in time you will understand that, but I have been in Bitcoinlandia for a long time and I've seen a lot of shit going on.
There - I fixed it for you.
reply
Nice post, would love to see more!
Do you know why Ligthing Addresses look like Email Addresses? I mean how can you distinguish them without context?
reply
Alby has that problem. The convention they established so that their browser extension can figure out the difference is to prefix the Lightning address with "āš”", so then when it looks at a Twitter profile, or a description in a Youtube video and sees:
āš”nym@stacker.news
it knows that is a Lightning address and it makes it a one-click step then to send that user a tip.
reply
for a HTML code it should have coded the difference using:
reply
Can still be done, right?
reply
Is not something that have to be implemented. Is already. You can do it yourself, if you have a web page, just use that HTML code. Other webmasters, just have to use that HTML code.
reply
It's not something that has to be implemented, as it is already implemented. You can do it yourself, if you have a web page, just use that HTML code. Other webmasters just have to use that HTML code.
There - I fixed it for you.
reply
I don't give a shit about "your fixes"... Stop trolling useless shit.
reply
Not trolling Darth - I'm genuinely trying to help you here.
I know you only dispense wisdom and have no ability to receive it, but if you only could take off the blinders for a second - what I'm saying could help you a lot.
reply
Ok, but that still seems error prone to me, especially outside of html. I think it would be better if they were easier to distinguish. I could even imagine that someone has already tried to send an email to a LN address.
reply
Great article, thanks for sharing
reply
Small correction from my side - "...which is encrypted using bech32 encoding".
Encryption - converting text to text using a secret key. No one who does not know this secret key can decrypt the message. Encoding - converting one form of text to another but without any key. It's just another representation of the same data and everybody can encode/decode.
bech32 is not encryption, it's encoding. Sorry for that.
reply
My god... Encryption - converting plaintext to ciphertext :D
reply
This is an excellent post, and very informative!
This is because some nodes learn a random number called payment_preimage when routing a payment, so it is not safe to pay one invoice multiple times, as fraud could occur.
I wouldn't mind learning more about this scenario for future posts.
reply
Thank you for this great post. I setup my own Lightning Address with my own domain a while ago. It's a wonderful feeling to be mostly host everything needed for this to be accomplished. Hopefully, after reading this post, more will follow in our footsteps. Lightning Addresses are the future of Lightning adoption, IMO.
reply
Nice explanation on LNURL. Quite informative and honestly, I know a lot more than earlier. Thx.
reply
nice post, cheers
reply
Thanks very much for this great post.
reply
Can you convert a lightning address into a static QR code just like the one that relates to LNURL ? or is that not possible. Thank you šŸ™šŸ¼ What would be the best option for static QR. code ?
reply
This is amazing !!! The lightning network is revolutionizing the world šŸ™ŒšŸ¼
reply
Great article! We'd love to publish it on bitcoinnews.com :)
reply
Every basic element of lightning and bitcoin should be published like this. Great article and very helpful.
reply
Very nice article. This was the intro I needed having not yet looked closely at LNURL.
However, when you say "your wallet will translate that into URL https://stacker.news/.well-known/lnurlp/heisenberg", do you mean there's an actual process of discovery not here described, or that the LNURL is a convention meaning that all websites serving LNURLs must follow this pattern so wallets can safely assume the final URL based on the username format?