Project

lnurl

0.01
The project is in a healthy, maintained state
A collection of tools to work with LNURLs - the protocol for interaction between Lightning wallets and third-party services.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.1
 Project Readme

LNURL tools for Ruby

LNURL is a protocol for interaction between Lightning wallets and third-party services.

This gem provides helpers to work with LNURLs from Ruby.

Links:

Installation

Add this line to your application's Gemfile:

gem 'lnurl'

Or install it yourself as:

$ gem install lnurl

Usage

Encoding

lnurl = Lnurl.new('https://lnurl.com/pay')
puts lnurl.to_bech32 # => LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW

Decoding

Lnurl.valid?('nolnurl') #=> false

lnurl = Lnurl.decode('LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW')
lnurl.uri # => #<URI::HTTPS https://lnurl.com/pay>

By default we accept long LNURLs but you can configure a custom max length:

lnurl = Lnurl.decode(a_short_lnurl, 90)
lnurl = Lnurl.from_lightning_address('user@lnurl.com')
lnurl.uri # => #<URI::HTTPS https://lnurl.com/.well-known/lnurlp/user>

LNURL responses

lnurl = Lnurl.decode('LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW')
response = lnurl.response # => #<Lnurl::LnurlResponse status="OK" ...
response.status # => OK / ERROR
response.callback # => https://...
response.tag # => payRequest
response.maxSendable # => 100000000
response.minSendable # => 1000
response.metadata # => [...]

invoice = response.request_invoice(amount: 100000) # (amount in msats) #<Lnurl::InvoiceResponse status="OK"
# or:
invoice = lnurl.request_invoice(amount: 100000) # (amount in msats)

invoice.status # => OK / ERROR
invoice.pr # => lntb20u1p0tdr7mpp...
invoice.successAction # => {...}
invoice.routes # => [...]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bumi/lnurl-ruby.

License

The gem is available as open source under the terms of the MIT License.