{"id":19001440,"url":"https://github.com/bumi/faraday_ln_paywall","last_synced_at":"2025-04-22T17:46:56.058Z","repository":{"id":56845542,"uuid":"154950641","full_name":"bumi/faraday_ln_paywall","owner":"bumi","description":"Faraday middleware to support bitcoin lightning paywalls. (pay per request)","archived":false,"fork":false,"pushed_at":"2019-06-02T09:57:36.000Z","size":44,"stargazers_count":10,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T22:03:11.364Z","etag":null,"topics":["api","bitcoin","faraday-middleware","lightning","lightning-network","lightning-paywalls","micropayments","payments","paywall"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bumi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-27T10:12:00.000Z","updated_at":"2024-07-13T22:53:11.000Z","dependencies_parsed_at":"2022-09-09T16:00:16.787Z","dependency_job_id":null,"html_url":"https://github.com/bumi/faraday_ln_paywall","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bumi%2Ffaraday_ln_paywall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bumi%2Ffaraday_ln_paywall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bumi%2Ffaraday_ln_paywall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bumi%2Ffaraday_ln_paywall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bumi","download_url":"https://codeload.github.com/bumi/faraday_ln_paywall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249283001,"owners_count":21243656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bitcoin","faraday-middleware","lightning","lightning-network","lightning-paywalls","micropayments","payments","paywall"],"created_at":"2024-11-08T18:11:10.658Z","updated_at":"2025-04-16T22:31:15.925Z","avatar_url":"https://github.com/bumi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Faraday middleware to send lightning payments\n\nThis is a [Faraday](https://github.com/lostisland/faraday#readme) middleware that handles payment requests by the server\nand sends Bitcoin [lightning payments](https://lightning.network/). \n\n\n## How does it work? \n\nThis Faraday middleware checks if the server responds with a `402 Payment Required` HTTP status code and \na lightning invoice ([BOLT11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md)).\nIf so it pays the invoice through the connected [lnd node](https://github.com/lightningnetwork/lnd/) and performs\na second request with the proof of payment. \n\n### How does the server side look like?\n\nHave a look at the [rack middleware rack-lightning for ruby](https://github.com/bumi/rack-lightning) \nor at [@philippgille's middleware for Go](https://github.com/philippgille/ln-paywall).\n\n\n## Requirements\n\nThe middleware uses the gRPC service provided by the [Lightning Network Daemon(lnd)](https://github.com/lightningnetwork/lnd/). \nA running node with funded channels is required. Details about lnd can be found on their [github page](https://github.com/lightningnetwork/lnd/)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'faraday_ln_paywall'\n```\n\n## Usage\n\nSimply use the `FaradayLnPaywall::Middleware` in your Faraday connection:\n\n```ruby\nconn = Faraday.new(:url =\u003e 'https://api.lightning.ws') do |faraday|\n  faraday.use FaradayLnPaywall::Middleware, { max_amount: 100 }\n  faraday.adapter  Faraday.default_adapter\nend\nputs conn.get(\"/translate?text=Danke\u0026to=en\").body\n\n```\n\n## Configuration\n\nThe middleware accepts the following configuration options: \n\n* `max_amount`: the maximum amount of an invoice that will automatically be paid. Raises a `FaradayLnPaywall::PaymentError` if the server request a higher amount\n* `address`: the address of the lnd gRPC service( default: `localhost:10009`)\n* `credentials_path`: path to the tls.cert (default: `~/.lnd/tls.cert`)\n* `macaroon_path`: path to the macaroon path (default: `~/.lnd/data/chain/bitcoin/testnet/admin.macaroon`)\n* `credentials`: instead of configuring a `credentials_path` you can pass the content of the tls.cert directly\n* `macaroon`: instead of configuring a `macaroon_path` you can pass the hex content of the macaroon directly\n    you can get the macaroon content like this:   \n    `xxd -p -c2000 admin.macaroon` or:\n    ```ruby\n    ::File.read(::File.expand_path(\"/path/to/admin.macaroon\")).each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join\n    ```\n\n## What is the Lightning Network?\n\nThe [Lightning Network](https://en.wikipedia.org/wiki/Lightning_Network) allows to send real near-instant microtransactions with extremely low fees. \nIt is a second layer on top of the Bitcoin network (and other crypto currencies). \nThanks to this properties it can be used to monetize APIs. \n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bumi/faraday_ln_paywall.\n\n## ToDo\n\n- [ ] tests!! \n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbumi%2Ffaraday_ln_paywall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbumi%2Ffaraday_ln_paywall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbumi%2Ffaraday_ln_paywall/lists"}