| 651 | }; |
| 652 | |
| 653 | static struct command_result * |
| 654 | send_modern_message(struct command *cmd, |
| 655 | struct tlv_onionmsg_payload_reply_path *reply_path, |
| 656 | struct sending *sending) |
| 657 | { |
| 658 | struct sent *sent = sending->sent; |
| 659 | struct privkey blinding_iter; |
| 660 | struct pubkey fwd_blinding, *node_alias; |
| 661 | size_t nhops = tal_count(sent->path); |
| 662 | struct tlv_onionmsg_payload **payloads; |
| 663 | struct out_req *req; |
| 664 | |
| 665 | /* Now create enctlvs for *forward* path. */ |
| 666 | randombytes_buf(&blinding_iter, sizeof(blinding_iter)); |
| 667 | if (!pubkey_from_privkey(&blinding_iter, &fwd_blinding)) |
| 668 | return command_fail(cmd, LIGHTNINGD, |
| 669 | "Could not convert blinding %s to pubkey!", |
| 670 | type_to_string(tmpctx, struct privkey, |
| 671 | &blinding_iter)); |
| 672 | |
| 673 | /* We overallocate: this node (0) doesn't have payload or alias */ |
| 674 | payloads = tal_arr(cmd, struct tlv_onionmsg_payload *, nhops); |
| 675 | node_alias = tal_arr(cmd, struct pubkey, nhops); |
| 676 | |
| 677 | for (size_t i = 1; i < nhops - 1; i++) { |
| 678 | payloads[i] = tlv_onionmsg_payload_new(payloads); |
| 679 | payloads[i]->encrypted_data_tlv = create_enctlv(payloads[i], |
| 680 | &blinding_iter, |
| 681 | &sent->path[i], |
| 682 | &sent->path[i+1], |
| 683 | /* FIXME: Pad? */ |
| 684 | 0, |
| 685 | NULL, |
| 686 | &blinding_iter, |
| 687 | &node_alias[i]); |
| 688 | } |
| 689 | /* Final payload contains the actual data. */ |
| 690 | payloads[nhops-1] = sending->payload; |
| 691 | |
| 692 | /* We don't include enctlv in final, but it gives us final alias */ |
| 693 | if (!create_final_enctlv(tmpctx, &blinding_iter, &sent->path[nhops-1], |
| 694 | /* FIXME: Pad? */ 0, |
| 695 | NULL, |
| 696 | &node_alias[nhops-1])) { |
| 697 | /* Should not happen! */ |
| 698 | return command_fail(cmd, LIGHTNINGD, |
| 699 | "Could create final enctlv"); |
| 700 | } |
| 701 | |
| 702 | payloads[nhops-1]->reply_path = reply_path; |
| 703 | |
| 704 | req = jsonrpc_request_start(cmd->plugin, cmd, "sendonionmessage", |
| 705 | sending->done, |
| 706 | forward_error, |
| 707 | sending->sent); |
| 708 | json_add_pubkey(req->js, "first_id", &sent->path[1]); |
| 709 | json_add_pubkey(req->js, "blinding", &fwd_blinding); |
| 710 | json_array_start(req->js, "hops"); |
no test coverage detected