mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
spec: import latest onionmessage spec, based on routeblinding.
This is from 6e99c5feaf60cb797507d181fe583224309318e9 We renamed the enctlv field to encrypted_recipient_data in the spec, and the new onion_message is message 513. We don't handle it until the next patch. Two renames: 1. blinding_seed -> blinding_point. 2. enctlv -> encrypted_recipient_data. We don't do a compat cycle for our JSON APIs for these experimental features only used by our own plugins, we just rename. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -164,12 +164,48 @@ json_to_obs2_reply_path(const tal_t *ctx, const char *buffer, const jsmntok_t *t
|
||||
rpath->path = tal_arr(rpath, struct onionmsg_path *, hops->size);
|
||||
json_for_each_arr(i, t, hops) {
|
||||
rpath->path[i] = tal(rpath->path, struct onionmsg_path);
|
||||
err = json_scan(tmpctx, buffer, t, "{id:%,enctlv:%}",
|
||||
err = json_scan(tmpctx, buffer, t, "{id:%,encrypted_recipient_data:%}",
|
||||
JSON_SCAN(json_to_pubkey,
|
||||
&rpath->path[i]->node_id),
|
||||
JSON_SCAN_TAL(rpath->path[i],
|
||||
json_tok_bin_from_hex,
|
||||
&rpath->path[i]->enctlv));
|
||||
&rpath->path[i]->encrypted_recipient_data));
|
||||
if (err)
|
||||
return tal_free(rpath);
|
||||
}
|
||||
|
||||
return rpath;
|
||||
}
|
||||
|
||||
struct tlv_onionmsg_payload_reply_path *
|
||||
json_to_reply_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok)
|
||||
{
|
||||
struct tlv_onionmsg_payload_reply_path *rpath;
|
||||
const jsmntok_t *hops, *t;
|
||||
size_t i;
|
||||
const char *err;
|
||||
|
||||
rpath = tal(ctx, struct tlv_onionmsg_payload_reply_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_path *, hops->size);
|
||||
json_for_each_arr(i, t, hops) {
|
||||
rpath->path[i] = tal(rpath->path, struct onionmsg_path);
|
||||
err = json_scan(tmpctx, buffer, t, "{id:%,encrypted_recipient_data:%}",
|
||||
JSON_SCAN(json_to_pubkey,
|
||||
&rpath->path[i]->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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user