| 648 | } |
| 649 | |
| 650 | struct tlv_onionmsg_payload_reply_path * |
| 651 | json_to_reply_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok) |
| 652 | { |
| 653 | struct tlv_onionmsg_payload_reply_path *rpath; |
| 654 | const jsmntok_t *hops, *t; |
| 655 | size_t i; |
| 656 | const char *err; |
| 657 | |
| 658 | rpath = tal(ctx, struct tlv_onionmsg_payload_reply_path); |
| 659 | err = json_scan(tmpctx, buffer, tok, "{blinding:%,first_node_id:%}", |
| 660 | JSON_SCAN(json_to_pubkey, &rpath->blinding), |
| 661 | JSON_SCAN(json_to_pubkey, &rpath->first_node_id), |
| 662 | NULL); |
| 663 | if (err) |
| 664 | return tal_free(rpath); |
| 665 | |
| 666 | hops = json_get_member(buffer, tok, "hops"); |
| 667 | if (!hops || hops->size < 1) |
| 668 | return tal_free(rpath); |
| 669 | |
| 670 | rpath->path = tal_arr(rpath, struct onionmsg_path *, hops->size); |
| 671 | json_for_each_arr(i, t, hops) { |
| 672 | rpath->path[i] = tal(rpath->path, struct onionmsg_path); |
| 673 | err = json_scan(tmpctx, buffer, t, "{id:%,encrypted_recipient_data:%}", |
| 674 | JSON_SCAN(json_to_pubkey, |
| 675 | &rpath->path[i]->node_id), |
| 676 | JSON_SCAN_TAL(rpath->path[i], |
| 677 | json_tok_bin_from_hex, |
| 678 | &rpath->path[i]->encrypted_recipient_data)); |
| 679 | if (err) |
| 680 | return tal_free(rpath); |
| 681 | } |
| 682 | |
| 683 | return rpath; |
| 684 | } |
| 685 | |
| 686 | |
| 687 | bool |
no test coverage detected