| 293 | } |
| 294 | |
| 295 | static void forward_event_notification_serialize(struct json_stream *stream, |
| 296 | const struct htlc_in *in, |
| 297 | const struct short_channel_id *scid_out, |
| 298 | const struct amount_msat *amount_out, |
| 299 | enum forward_status state, |
| 300 | enum onion_wire failcode, |
| 301 | struct timeabs *resolved_time, |
| 302 | enum forward_style forward_style) |
| 303 | { |
| 304 | /* Here is more neat to initial a forwarding structure than |
| 305 | * to pass in a bunch of parameters directly*/ |
| 306 | struct forwarding *cur = tal(tmpctx, struct forwarding); |
| 307 | |
| 308 | /* We use the LOCAL alias, not the REMOTE, despite the route |
| 309 | * the the sender is using probably using the REMOTE |
| 310 | * alias. The LOCAL one is controlled by us, and we keep it |
| 311 | * stable. */ |
| 312 | cur->channel_in = *channel_scid_or_local_alias(in->key.channel); |
| 313 | |
| 314 | cur->msat_in = in->msat; |
| 315 | if (scid_out) { |
| 316 | cur->channel_out = *scid_out; |
| 317 | if (amount_out) { |
| 318 | cur->msat_out = *amount_out; |
| 319 | if (!amount_msat_sub(&cur->fee, |
| 320 | in->msat, *amount_out)) |
| 321 | abort(); |
| 322 | } else { |
| 323 | cur->msat_out = AMOUNT_MSAT(0); |
| 324 | cur->fee = AMOUNT_MSAT(0); |
| 325 | } |
| 326 | } else { |
| 327 | cur->channel_out.u64 = 0; |
| 328 | cur->msat_out = AMOUNT_MSAT(0); |
| 329 | cur->fee = AMOUNT_MSAT(0); |
| 330 | } |
| 331 | cur->htlc_id_out = NULL; |
| 332 | cur->status = state; |
| 333 | cur->failcode = failcode; |
| 334 | cur->received_time = in->received_time; |
| 335 | cur->resolved_time = tal_steal(cur, resolved_time); |
| 336 | cur->forward_style = forward_style; |
| 337 | cur->htlc_id_in = in->key.id; |
| 338 | |
| 339 | json_add_forwarding_object(stream, "forward_event", |
| 340 | cur, &in->payment_hash); |
| 341 | } |
| 342 | |
| 343 | REGISTER_NOTIFICATION(forward_event, |
| 344 | forward_event_notification_serialize); |
nothing calls this directly
no test coverage detected