forked from such-gitea/wownero-lws
Add ZMQ-PUB support for webhooks (#75)
This commit is contained in:
committed by
Lee *!* Clagett
parent
d59fed6da2
commit
15e2be618a
@@ -146,23 +146,27 @@ height.
|
||||
### webhook_add
|
||||
This is used to track a specific payment ID to an address or all general
|
||||
payments to an address (where payment ID is zero). Using this endpint requires
|
||||
a web address for callback purposes, a primary (not integrated!) address, and
|
||||
finally the type ("tx-confirmation"). The event will remain in the database
|
||||
until one of the delete commands ([webhook_delete_uuid](#webhook_delete_uuid)
|
||||
or [webhook_delete](#webhook_delete)) is used to remove it.
|
||||
a web address or `zmq` for callback purposes, a primary (not integrated!)
|
||||
address, and finally the type ("tx-confirmation"). The event will remain in the
|
||||
database until one of the delete commands ([webhook_delete_uuid](#webhook_delete_uuid)
|
||||
or [webhook_delete](#webhook_delete)) is used to remove it. All webhooks are
|
||||
published over the ZMQ socket specified by `--zmq-pub` (when enabled/specified
|
||||
on command line) in addition to any HTTP server specified in the callback.
|
||||
|
||||
> The provided URL will use SSL/TLS if `https://` is prefixed in the URL and
|
||||
will use plaintext if `http://` is prefixed in the URL. SSL/TLS connections
|
||||
will use the system certificate authority (root-CAs) by default, and will
|
||||
ignore all authority checks if `--webhook-ssl-verification none` is provided
|
||||
on the command line when starting `monero-lws-daemon`. The webhook will fail
|
||||
if there is a mismatch of `http` and `https` between the two servers, and
|
||||
will also fail if `https` verification is mismatched. The rule is: (1) if
|
||||
the callback server has SSL/TLS disabled, the webhook should use `http://`,
|
||||
(2) if the callback server has a self-signed certificate, `https://` and
|
||||
`--webhook-ssl-verification none` should be used, and (3) if the callback
|
||||
server is using "Let's Encrypt" (or similar), then `https://` with no
|
||||
additional command line flag should be used.
|
||||
will use plaintext if `http://` is prefixed in the URL. If `zmq` is provided
|
||||
as the callback, notifications are performed _only_ over the ZMQ pub socket.
|
||||
SSL/TLS connections will use the system certificate authority (root-CAs) by
|
||||
default, and will ignore all authority checks if
|
||||
`--webhook-ssl-verification none` is provided on the command line when
|
||||
starting `monero-lws-daemon`. The webhook will fail if there is a mismatch of
|
||||
`http` and `https` between the two servers, and will also fail if `https`
|
||||
verification is mismatched. The rule is: (1) if the callback server has
|
||||
SSL/TLS disabled, the webhook should use `http://`, (2) if the callback server
|
||||
has a self-signed certificate, `https://` and `--webhook-ssl-verification none`
|
||||
should be used, and (3) if the callback server is using "Let's Encrypt"
|
||||
(or similar), then `https://` with no additional command line flag should be
|
||||
used.
|
||||
|
||||
|
||||
#### Initial Request to server
|
||||
|
||||
65
docs/zmq.md
Normal file
65
docs/zmq.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# monero-lws ZeroMQ Usage
|
||||
Monero-lws uses ZeroMQ-RPC to retrieve information from a Monero daemon,
|
||||
ZeroMQ-SUB to get immediate notifications of blocks and transactions from a
|
||||
Monero daemon, and ZeroMQ-PUB to notify external applications of payment_id
|
||||
(web)hooks.
|
||||
|
||||
## External "pub" socket
|
||||
The bind location of the ZMQ-PUB socket is specified with the `--zmq-pub`
|
||||
option. Users are still required to "subscribe" to topics:
|
||||
* `json-full-pyment_hook`: A JSON array of webhook payment events that have
|
||||
recently triggered (identical output as webhook).
|
||||
* `msgpack-full-payment_hook`: A msgpack array of webhook payment events that
|
||||
have recently triggered (identical output as webhook).
|
||||
|
||||
|
||||
### `json-full-payment_hook`/`msgpack-full-payment_hook`
|
||||
These topics receive PUB messages when a webhook ([`webhook_add`](administration.md)),
|
||||
event is triggered. If the specified URL is `zmq`, then notifications are only
|
||||
done over the ZMQ-PUB socket, otherwise the notification is sent over ZMQ-PUB
|
||||
socket AND the specified URL. Invoking `webhook_add` with a `payment_id` of
|
||||
zeroes (the field is optional in `webhook_add), will match on all transactions
|
||||
that lack a `payment_id`.
|
||||
|
||||
Example of the "raw" output from ZMQ-SUB side:
|
||||
|
||||
```json
|
||||
json-full-payment_hook:{
|
||||
"index": 2,
|
||||
"event": {
|
||||
"event": "tx-confirmation",
|
||||
"payment_id": "4f695d197f2a3c54",
|
||||
"token": "single zmq wallet",
|
||||
"confirmations": 1,
|
||||
"event_id": "3894f98f5dd54af5857e4f8a961a4e57",
|
||||
"tx_info": {
|
||||
"id": {
|
||||
"high": 0,
|
||||
"low": 5666768
|
||||
},
|
||||
"block": 2265961,
|
||||
"index": 1,
|
||||
"amount": 3117324236131,
|
||||
"timestamp": 1687301600,
|
||||
"tx_hash": "ef3187775584351cc5109de124b877bcc530fb3fdbf77895329dd447902cc566",
|
||||
"tx_prefix_hash": "064884b8a8f903edcfebab830707ed44b633438b47c95a83320f4438b1b28626",
|
||||
"tx_public": "54dce1a6eebafa2fdedcea5e373ef9de1c3d2737ae9f809e80958d1ba4590d74",
|
||||
"rct_mask": "4cdc4c4e340aacb4741ba20f9b0b859242ecdad2fcc251f71d81123a47db3400",
|
||||
"payment_id": "4f695d197f2a3c54",
|
||||
"unlock_time": 0,
|
||||
"mixin_count": 15,
|
||||
"coinbase": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Notice the `json-full-payment_hook:` prefix - this is required for the ZMQ PUB/SUB
|
||||
subscription model. The subscriber requests data from a certain "topic" where
|
||||
matching is done by string prefixes.
|
||||
|
||||
> `index` is a counter used to detect dropped messages.
|
||||
|
||||
> The `block` and `id` fields in the above example are NOT present when
|
||||
`confirmations == 0`.
|
||||
Reference in New Issue
Block a user