|
| 1 | +## The `webhook` plugin. |
| 2 | + |
| 3 | +This plugin sends a webhook to any URL when a payment is received, sent or forwarded. It supports filtering just some of these events and dispatching the webhooks to multiple URLs (each can have its own filtering policies). |
| 4 | + |
| 5 | +It supports [all of the notification types lightningd produces](https://lightning.readthedocs.io/PLUGINS.html#notification-types). However, by default it will only dispatch `invoice_payment` and `sendpay_success`. The others are available only if you specify them explicitly in the URL querystring (see below). |
| 6 | + |
| 7 | +The payload sent for each webhook is the _inner object_ of the payload given by lightningd. For example, for `invoice_payment` it will be `{"label": "unique-label-for-invoice", "preimage": "0000000000000000000000000000000000000000000000000000000000000000", "msat": "10000msat" }`. |
| 8 | + |
| 9 | +## How to install |
| 10 | + |
| 11 | +This is distributed as a single binary for your delight (or you can compile it yourself with `go get`). |
| 12 | + |
| 13 | +[Download it](https://github.com/fiatjaf/lightningd-webhook/releases), call `chmod +x <binary>` and put it in `~/.lightning/plugins` (create that directory if it doesn't exist). |
| 14 | + |
| 15 | +You only need the binary you can get in [the releases page](https://github.com/fiatjaf/lightningd-webhook/releases), nothing else. |
| 16 | + |
| 17 | +## How to use |
| 18 | + |
| 19 | +Initialize `lightningd` passing the option `--webhook=https://your.url/here` and that's it. You can also write that in your `~/.lightning/config` file. A nice place to get webhook endpoints for a quick test is https://beeceptor.com/. |
| 20 | + |
| 21 | +### Multiple URLs |
| 22 | + |
| 23 | +To dispatch webhooks to multiple URLs, write them separated by commas, like `--webhook=https://first.url/,https://second.url/`. |
| 24 | + |
| 25 | +### Filter events |
| 26 | + |
| 27 | +You can opt to receive only `payment`, `invoice` or `forward` events. To filter (in each URL) append a querystring parameter like `?filter-event=invoice` to the URL. You can repeat that parameter. If no parameters are given, `invoice_payment` and `sendpay_success` events will be dispatched. |
| 28 | + |
| 29 | +### Example |
| 30 | + |
| 31 | +With the following line in `~/.lightning/config`: |
| 32 | + |
| 33 | +``` |
| 34 | +webhook=https://myurl.com/myhandler?filter-event=invoice_payment |
| 35 | +``` |
| 36 | + |
| 37 | +You'll get payloads like these: |
| 38 | + |
| 39 | +```json |
| 40 | +{ |
| 41 | + "invoice_payment": { |
| 42 | + "label": "unique-label-for-invoice", |
| 43 | + "preimage": "0000000000000000000000000000000000000000000000000000000000000000", |
| 44 | + "msat": "10000msat" |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +## Built with [github.com/fiatjaf/lightningd-gjson-rpc](https://pkg.go.dev/github.com/fiatjaf/lightningd-gjson-rpc/plugin?tab=doc) |
0 commit comments