Skip to content

Commit e655f69

Browse files
committed
lightningd: notification for onionmessage_forward_fail.
Changelog-Added: Plugins: new notification `onionmessage_forward_fail`. Signed-off-by: Rusty Russell <[email protected]>
1 parent 8e4b589 commit e655f69

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

lightningd/connect_control.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,31 @@ static void handle_custommsg_in(struct lightningd *ld, const u8 *msg)
369369

370370
static void handle_onionmsg_forward_fail(struct lightningd *ld, const u8 *msg)
371371
{
372-
/* FIXME: Do something! */
372+
struct node_id source;
373+
u8 *incoming;
374+
struct pubkey path_key;
375+
u8 *outgoing;
376+
struct sciddir_or_pubkey *next;
377+
378+
if (!fromwire_connectd_onionmsg_forward_fail(tmpctx, msg,
379+
&source,
380+
&incoming,
381+
&path_key,
382+
&outgoing,
383+
&next)) {
384+
log_broken(ld->log, "Malformed onionmsg_forward_fail: %s",
385+
tal_hex(tmpctx, msg));
386+
return;
387+
}
388+
389+
if (tal_count(outgoing) && !next) {
390+
log_broken(ld->log, "onionmsg_forward_fail missing next: %s",
391+
tal_hex(tmpctx, msg));
392+
return;
393+
}
394+
395+
notify_onionmessage_forward_fail(ld, &source, incoming,
396+
&path_key, outgoing, next);
373397
}
374398

375399
static void connectd_start_shutdown_reply(struct subd *connectd,

lightningd/notification.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,45 @@ void notify_custommsg(struct lightningd *ld,
176176
notify_send(ld, n);
177177
}
178178

179+
static void onionmessage_forward_fail_serialize(struct json_stream *stream,
180+
const struct node_id *source,
181+
const u8 *incoming,
182+
const struct pubkey *path_key,
183+
const u8 *outgoing,
184+
const struct sciddir_or_pubkey *next_node)
185+
{
186+
json_add_node_id(stream, "source", source);
187+
json_add_hex_talarr(stream, "incoming", incoming);
188+
json_add_pubkey(stream, "path_key", path_key);
189+
if (tal_count(outgoing) != 0) {
190+
json_add_hex_talarr(stream, "outgoing", outgoing);
191+
if (next_node->is_pubkey)
192+
json_add_pubkey(stream, "next_node_id", &next_node->pubkey);
193+
else
194+
json_add_short_channel_id_dir(stream, "next_short_channel_id_dir",
195+
next_node->scidd);
196+
}
197+
}
198+
199+
REGISTER_NOTIFICATION(onionmessage_forward_fail);
200+
201+
void notify_onionmessage_forward_fail(struct lightningd *ld,
202+
const struct node_id *source,
203+
const u8 *incoming,
204+
const struct pubkey *path_key,
205+
const u8 *outgoing,
206+
const struct sciddir_or_pubkey *next_node)
207+
{
208+
struct jsonrpc_notification *n = notify_start("onionmessage_forward_fail");
209+
onionmessage_forward_fail_serialize(n->stream,
210+
source,
211+
incoming,
212+
path_key,
213+
outgoing,
214+
next_node);
215+
notify_send(ld, n);
216+
}
217+
179218
static void invoice_payment_notification_serialize(struct json_stream *stream,
180219
struct amount_msat amount,
181220
const struct preimage *preimage,

lightningd/notification.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ void notify_openchannel_peer_sigs(struct lightningd *ld,
9999
void notify_channel_open_failed(struct lightningd *ld,
100100
const struct channel_id *cid);
101101

102+
void notify_onionmessage_forward_fail(struct lightningd *ld,
103+
const struct node_id *source,
104+
const u8 *incoming,
105+
const struct pubkey *path_key,
106+
const u8 *outgoing,
107+
const struct sciddir_or_pubkey *next_node);
108+
102109
/* Tell this plugin about deprecated flag for next: returns false
103110
* if doesn't subscribe */
104111
bool notify_deprecated_oneshot(struct lightningd *ld,

0 commit comments

Comments
 (0)