Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bumi/lnurl-ruby
LNURL tools for Ruby
https://github.com/bumi/lnurl-ruby
bitcoin lightning lightning-network lnurl
Last synced: 4 days ago
JSON representation
LNURL tools for Ruby
- Host: GitHub
- URL: https://github.com/bumi/lnurl-ruby
- Owner: bumi
- License: mit
- Created: 2020-05-07T19:13:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-05T13:24:17.000Z (3 months ago)
- Last Synced: 2024-10-05T17:16:10.190Z (about 1 month ago)
- Topics: bitcoin, lightning, lightning-network, lnurl
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 10
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this 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:
* [LNURL: Lightning Network UX protocol RFC](https://github.com/btcontract/lnurl-rfc)
* [Awesome LNURL - a curated list with things related to LNURL](https://github.com/fiatjaf/awesome-lnurl)
* [LNURL pay flow](https://xn--57h.bigsun.xyz/lnurl-pay-flow.txt)## Installation
Add this line to your application's Gemfile:
```ruby
gem 'lnurl'
```Or install it yourself as:
$ gem install lnurl
## Usage
### Encoding
```ruby
lnurl = Lnurl.new('https://lnurl.com/pay')
puts lnurl.to_bech32 # => LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW
```### Decoding
```ruby
Lnurl.valid?('nolnurl') #=> falselnurl = Lnurl.decode('LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW')
lnurl.uri # => #
```By default we accept long LNURLs but you can configure a custom max length:
```ruby
lnurl = Lnurl.decode(a_short_lnurl, 90)
```### [Lightning Address](https://github.com/andrerfneves/lightning-address)
```ruby
lnurl = Lnurl.from_lightning_address('[email protected]')
lnurl.uri # => #
```### LNURL responses
```ruby
lnurl = Lnurl.decode('LNURL1DP68GURN8GHJ7MRWW4EXCTNRDAKJ7URP0YVM59LW')
response = lnurl.response # => # 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) # 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](https://opensource.org/licenses/MIT).