| 361 | } |
| 362 | |
| 363 | struct command_result *handle_invoice_onion_message(struct command *cmd, |
| 364 | const char *buf, |
| 365 | const jsmntok_t *om, |
| 366 | const struct secret *pathsecret) |
| 367 | { |
| 368 | struct sent *sent; |
| 369 | struct command_result *err; |
| 370 | |
| 371 | /* BOLT #4: |
| 372 | * - otherwise (it is the final node): |
| 373 | * - if `path_id` is set and corresponds to a path the reader has previously published in a `reply_path`: |
| 374 | * - if the onion message is not a reply to that previous onion: |
| 375 | * - MUST ignore the onion message |
| 376 | * - otherwise (unknown or unset `path_id`): |
| 377 | * - if the onion message is a reply to an onion message which contained a `path_id`: |
| 378 | * - MUST respond (or not respond) exactly as if it did not send the initial onion message. |
| 379 | */ |
| 380 | /* We unmarshal the path_id into our secret: if it is NULL or wrong, we exit here */ |
| 381 | sent = find_sent_by_secret(pathsecret); |
| 382 | if (!sent) |
| 383 | return NULL; |
| 384 | |
| 385 | plugin_log(cmd->plugin, LOG_DBG, "Received onion message reply for invoice_request: %.*s", |
| 386 | json_tok_full_len(om), |
| 387 | json_tok_full(buf, om)); |
| 388 | |
| 389 | err = handle_error(cmd, sent, buf, om); |
| 390 | if (err) |
| 391 | return err; |
| 392 | |
| 393 | if (sent->invreq) |
| 394 | return handle_invreq_response(cmd, sent, buf, om); |
| 395 | |
| 396 | return NULL; |
| 397 | } |
| 398 | |
| 399 | static void destroy_sent(struct sent *sent) |
| 400 | { |
no test coverage detected