| 35 | } |
| 36 | |
| 37 | static bool decrypt_forwarding_onionmsg(const struct pubkey *path_key, |
| 38 | const struct secret *ss, |
| 39 | const u8 *enctlv, |
| 40 | struct sciddir_or_pubkey *next_node, |
| 41 | struct pubkey *next_path_key) |
| 42 | { |
| 43 | struct tlv_encrypted_data_tlv *encmsg; |
| 44 | |
| 45 | encmsg = decrypt_encrypted_data(tmpctx, ss, enctlv); |
| 46 | if (!encmsg) |
| 47 | return false; |
| 48 | |
| 49 | /* BOLT #4: |
| 50 | * - if it is not the final node according to the onion encryption: |
| 51 | *... |
| 52 | * - if the `encrypted_data_tlv` contains `path_id`: |
| 53 | * - MUST ignore the message. |
| 54 | */ |
| 55 | if (encmsg->path_id) |
| 56 | return false; |
| 57 | |
| 58 | /* BOLT #4: |
| 59 | * - if it is not the final node according to the onion encryption: |
| 60 | *... |
| 61 | * - if `next_node_id` is present: |
| 62 | * - the *next peer* is the peer with that node id. |
| 63 | * - otherwise, if `short_channel_id` is present and corresponds to an announced short_channel_id or a local alias for a channel: |
| 64 | * - the *next peer* is the peer at the other end of that channel. |
| 65 | * - otherwise: |
| 66 | * - MUST ignore the message. |
| 67 | */ |
| 68 | if (encmsg->next_node_id) |
| 69 | sciddir_or_pubkey_from_pubkey(next_node, encmsg->next_node_id); |
| 70 | else if (encmsg->short_channel_id) { |
| 71 | /* This is actually scid, not sciddir, but the type is convenient! */ |
| 72 | struct short_channel_id_dir scidd; |
| 73 | scidd.scid = *encmsg->short_channel_id; |
| 74 | scidd.dir = 0; |
| 75 | sciddir_or_pubkey_from_scidd(next_node, &scidd); |
| 76 | } else |
| 77 | return false; |
| 78 | |
| 79 | blindedpath_next_path_key(encmsg, path_key, ss, next_path_key); |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | /* Returns false on failure */ |
| 84 | const char *onion_message_parse(const tal_t *ctx, |
no test coverage detected