Skip to content

Commit 5c93f12

Browse files
nepetcdecker
authored andcommitted
lightningd: add peer_id to htlc_accepted_hook
In some cases it is helpful to know who offered us the HTLC. Changelog-Changed: Plugins: The `htlc_accepted` hook now knows the `peer_id` of the peer that offered us the HTLC. Signed-off-by: Peter Neuroth <[email protected]>
1 parent 85e97bf commit 5c93f12

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

doc/developers-guide/plugin-development/hooks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ The payload of the hook call has the following format:
400400

401401
```json
402402
{
403+
"peer_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f",
403404
"onion": {
404405
"payload": "",
405406
"short_channel_id": "1x2x3",
@@ -425,6 +426,7 @@ The payload of the hook call has the following format:
425426

426427
For detailed information about each field please refer to [BOLT 04 of the specification](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), the following is just a brief summary:
427428

429+
- `peer_id`: is the id of the peer that offered us this htlc.
428430
- `onion`:
429431
- `payload` contains the unparsed payload that was sent to us from the sender of the payment.
430432
- `short_channel_id` determines the channel that the sender is hinting should be used next. Not present if we're the final destination.

lightningd/peer_htlcs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,9 @@ static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p,
11931193
tal_fmt(hin, "Waiting for the htlc_accepted hook of plugin %s",
11941194
plugin->shortname);
11951195

1196+
if (p->channel && p->channel->peer)
1197+
json_add_node_id(s, "peer_id", &p->channel->peer->id);
1198+
11961199
json_object_start(s, "onion");
11971200

11981201
json_add_hex_talarr(s, "payload", rs->raw_payload);

0 commit comments

Comments
 (0)