Skip to content

Commit 4b75790

Browse files
author
fiatjaf
committed
migrate from the other repo.
0 parents  commit 4b75790

File tree

6 files changed

+416
-0
lines changed

6 files changed

+416
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
webhook

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist: $(shell find . -name "*.go")
2+
mkdir -p dist
3+
gox -ldflags="-s -w" -tags="full" -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm freebsd/amd64" -output="dist/webhook_{{.OS}}_{{.Arch}}"

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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)

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/fiatjaf/lightningd-webhook
2+
3+
go 1.14
4+
5+
require github.com/fiatjaf/lightningd-gjson-rpc v1.0.1

0 commit comments

Comments
 (0)