MCPcopy Create free account
hub / github.com/ElementsProject/lightning / forward_event_notification_serialize

Function forward_event_notification_serialize

lightningd/notification.c:348–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348static void forward_event_notification_serialize(struct json_stream *stream,
349 const struct htlc_in *in,
350 const struct short_channel_id *scid_out,
351 const struct amount_msat *amount_out,
352 enum forward_status state,
353 enum onion_wire failcode,
354 struct timeabs *resolved_time,
355 enum forward_style forward_style,
356 u64 created_index,
357 u64 updated_index)
358{
359 /* Here is more neat to initial a forwarding structure than
360 * to pass in a bunch of parameters directly*/
361 struct forwarding *cur = tal(tmpctx, struct forwarding);
362
363 /* We use the LOCAL alias, not the REMOTE, despite the route
364 * the the sender is using probably using the REMOTE
365 * alias. The LOCAL one is controlled by us, and we keep it
366 * stable. */
367 cur->channel_in = channel_scid_or_local_alias(in->key.channel);
368
369 cur->msat_in = in->msat;
370 if (scid_out) {
371 cur->channel_out = *scid_out;
372 if (amount_out) {
373 cur->msat_out = *amount_out;
374 if (!amount_msat_sub(&cur->fee,
375 in->msat, *amount_out))
376 abort();
377 } else {
378 cur->msat_out = AMOUNT_MSAT(0);
379 cur->fee = AMOUNT_MSAT(0);
380 }
381 } else {
382 cur->channel_out.u64 = 0;
383 cur->msat_out = AMOUNT_MSAT(0);
384 cur->fee = AMOUNT_MSAT(0);
385 }
386 cur->htlc_id_out = NULL;
387 cur->status = state;
388 cur->failcode = failcode;
389 cur->received_time = in->received_time;
390 cur->resolved_time = tal_steal(cur, resolved_time);
391 cur->forward_style = forward_style;
392 cur->htlc_id_in = in->key.id;
393 cur->created_index = created_index;
394 cur->updated_index = updated_index;
395 json_add_forwarding_fields(stream, cur, &in->payment_hash, in->preimage);
396}
397
398REGISTER_NOTIFICATION(forward_event);
399

Callers 1

notify_forward_eventFunction · 0.85

Calls 4

amount_msat_subFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected