Create path to node which can carry onion messages (including * self); if it can't find one, returns NULL. Fills in nodeid_parity * for 33rd nodeid byte. */
| 587 | * self); if it can't find one, returns NULL. Fills in nodeid_parity |
| 588 | * for 33rd nodeid byte. */ |
| 589 | static struct pubkey *path_to_node(const tal_t *ctx, |
| 590 | struct plugin *plugin, |
| 591 | const struct point32 *node32_id, |
| 592 | enum nodeid_parity *parity) |
| 593 | { |
| 594 | struct route_hop *r; |
| 595 | const struct dijkstra *dij; |
| 596 | const struct gossmap_node *src; |
| 597 | const struct gossmap_node *dst; |
| 598 | struct node_id dstid, local_nodeid; |
| 599 | struct pubkey *nodes; |
| 600 | struct gossmap *gossmap = get_gossmap(plugin); |
| 601 | |
| 602 | /* We try both parities. */ |
| 603 | *parity = nodeid_parity_even; |
| 604 | node_id_from_point32(&dstid, node32_id, *parity); |
| 605 | dst = gossmap_find_node(gossmap, &dstid); |
| 606 | if (!dst) { |
| 607 | *parity = nodeid_parity_odd; |
| 608 | node_id_from_point32(&dstid, node32_id, *parity); |
| 609 | dst = gossmap_find_node(gossmap, &dstid); |
| 610 | if (!dst) { |
| 611 | *parity = nodeid_parity_unknown; |
| 612 | return NULL; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | *parity = node_parity(gossmap, dst); |
| 617 | |
| 618 | /* If we don't exist in gossip, routing can't happen. */ |
| 619 | node_id_from_pubkey(&local_nodeid, &local_id); |
| 620 | src = gossmap_find_node(gossmap, &local_nodeid); |
| 621 | if (!src) |
| 622 | return NULL; |
| 623 | |
| 624 | dij = dijkstra(tmpctx, gossmap, dst, AMOUNT_MSAT(0), 0, |
| 625 | can_carry_onionmsg, route_score_shorter, NULL); |
| 626 | |
| 627 | r = route_from_dijkstra(tmpctx, gossmap, dij, src, AMOUNT_MSAT(0), 0); |
| 628 | if (!r) |
| 629 | return NULL; |
| 630 | |
| 631 | nodes = tal_arr(ctx, struct pubkey, tal_count(r) + 1); |
| 632 | nodes[0] = local_id; |
| 633 | for (size_t i = 0; i < tal_count(r); i++) { |
| 634 | if (!pubkey_from_node_id(&nodes[i+1], &r[i].node_id)) { |
| 635 | plugin_err(plugin, "Could not convert nodeid %s", |
| 636 | type_to_string(tmpctx, struct node_id, |
| 637 | &r[i].node_id)); |
| 638 | } |
| 639 | } |
| 640 | return nodes; |
| 641 | } |
| 642 | |
| 643 | /* Marshal arguments for sending onion messages */ |
| 644 | struct sending { |
no test coverage detected