forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common: move json_to_blinded_path into its own file.
It's fairly obscure, and let's not make everyone link it. Signed-off-by: Rusty Russell <[email protected]>
- Loading branch information
1 parent
7eb72c5
commit 1b9b160
Showing
7 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "config.h" | ||
#include <common/json_blinded_path.h> | ||
#include <common/json_parse.h> | ||
#include <wire/onion_wire.h> | ||
|
||
struct blinded_path * | ||
json_to_blinded_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok) | ||
{ | ||
struct blinded_path *rpath; | ||
const jsmntok_t *hops, *t; | ||
size_t i; | ||
const char *err; | ||
|
||
rpath = tal(ctx, struct blinded_path); | ||
err = json_scan(tmpctx, buffer, tok, "{blinding:%,first_node_id:%}", | ||
JSON_SCAN(json_to_pubkey, &rpath->blinding), | ||
JSON_SCAN(json_to_pubkey, &rpath->first_node_id), | ||
NULL); | ||
if (err) | ||
return tal_free(rpath); | ||
|
||
hops = json_get_member(buffer, tok, "hops"); | ||
if (!hops || hops->size < 1) | ||
return tal_free(rpath); | ||
|
||
rpath->path = tal_arr(rpath, struct onionmsg_hop *, hops->size); | ||
json_for_each_arr(i, t, hops) { | ||
rpath->path[i] = tal(rpath->path, struct onionmsg_hop); | ||
err = json_scan(tmpctx, buffer, t, "{blinded_node_id:%,encrypted_recipient_data:%}", | ||
JSON_SCAN(json_to_pubkey, | ||
&rpath->path[i]->blinded_node_id), | ||
JSON_SCAN_TAL(rpath->path[i], | ||
json_tok_bin_from_hex, | ||
&rpath->path[i]->encrypted_recipient_data)); | ||
if (err) | ||
return tal_free(rpath); | ||
} | ||
|
||
return rpath; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef LIGHTNING_COMMON_JSON_BLINDED_PATH_H | ||
#define LIGHTNING_COMMON_JSON_BLINDED_PATH_H | ||
#include "config.h" | ||
#include <common/json_parse_simple.h> | ||
|
||
/* Extract reply path from this JSON */ | ||
struct blinded_path * | ||
json_to_blinded_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok); | ||
|
||
#endif /* LIGHTNING_COMMON_JSON_BLINDED_PATH_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters