MCPcopy Create free account
hub / github.com/ElementsProject/lightning / param_bip353

Function param_bip353

plugins/fetchinvoice.c:922–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920}
921
922static struct command_result *param_bip353(struct command *cmd, const char *name,
923 const char *buffer, const jsmntok_t *tok,
924 struct bip_353_name **bip353)
925{
926 char *str, *at;
927
928 /* BOLT #12:
929 * - if it received the offer from which it constructed this
930 * `invoice_request` using BIP 353 resolution:
931 * - MUST include `invreq_bip_353_name` with,
932 * - `name` set to the post-₿, pre-@ part of the BIP 353 HRN,
933 * - `domain` set to the post-@ part of the BIP 353 HRN.
934 */
935 str = json_strdup(tmpctx, buffer, tok);
936 if (!utf8_check(str, strlen(str)))
937 return command_fail_badparam(cmd, name, buffer, tok, "invalid UTF-8");
938
939 at = strchr(str, '@');
940 if (!at)
941 return command_fail_badparam(cmd, name, buffer, tok, "missing @");
942
943 /* Strip ₿ if present (0xE2 0x82 0xBF) */
944 if (strstarts(str, "₿"))
945 str += strlen("₿");
946
947 *bip353 = tal(cmd, struct bip_353_name);
948 /* Not nul-terminated! */
949 (*bip353)->name
950 = tal_dup_arr(*bip353, u8, (const u8 *)str, at - str, 0);
951 (*bip353)->domain
952 = tal_dup_arr(*bip353, u8, (const u8 *)at + 1, strlen(at + 1), 0);
953
954 return NULL;
955}
956
957/* Fetches an invoice for this offer, and makes sure it corresponds. */
958struct command_result *json_fetchinvoice(struct command *cmd,

Callers

nothing calls this directly

Calls 3

json_strdupFunction · 0.50
utf8_checkFunction · 0.50
command_fail_badparamFunction · 0.50

Tested by

no test coverage detected