| 527 | } |
| 528 | |
| 529 | static struct command_result *establish_path_done(struct command *cmd, |
| 530 | const struct pubkey *path, |
| 531 | struct establishing_paths *epaths) |
| 532 | { |
| 533 | struct onion_message *omsg; |
| 534 | struct sent *sent = epaths->sent; |
| 535 | struct tlv_onionmsg_tlv *final_tlv = epaths->final_tlv; |
| 536 | |
| 537 | /* Create transient secret so we can validate reply! */ |
| 538 | sent->reply_secret = tal(sent, struct secret); |
| 539 | |
| 540 | assert(tal_count(path) > 0); |
| 541 | |
| 542 | /* Add reply path to final_tlv (it already contains invoice_request/invoice) */ |
| 543 | if (epaths->want_reply) { |
| 544 | final_tlv->reply_path = make_reply_path(final_tlv, cmd->plugin, sent, path, sent->reply_secret); |
| 545 | |
| 546 | /* Replace first hop with scidd if they said to */ |
| 547 | if (sent->dev_path_use_scidd) |
| 548 | sciddir_or_pubkey_from_scidd(&final_tlv->reply_path->first_node_id, |
| 549 | sent->dev_path_use_scidd); |
| 550 | } |
| 551 | |
| 552 | /* Put in list so we recognize reply onion message. Note: because |
| 553 | * onion message notification comes from a different fd than the one |
| 554 | * we send this command to, it can actually be processed *before* we |
| 555 | * call done() */ |
| 556 | sent->cmd = cmd; |
| 557 | list_add_tail(&sent_list, &sent->list); |
| 558 | tal_add_destructor(sent, destroy_sent); |
| 559 | |
| 560 | omsg = outgoing_onion_message(tmpctx, path, NULL, current_their_path(epaths), final_tlv); |
| 561 | return inject_onionmessage(cmd, omsg, epaths->done, forward_error, sent); |
| 562 | } |
| 563 | |
| 564 | /* Mutual recursion */ |
| 565 | static struct command_result *try_establish(struct command *cmd, |
nothing calls this directly
no test coverage detected