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

Function json_add_invreq_fields

plugins/offers.c:1056–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1054}
1055
1056static bool json_add_invreq_fields(struct command *cmd,
1057 struct json_stream *js,
1058 const u8 *invreq_metadata,
1059 const struct bitcoin_blkid *invreq_chain,
1060 const u64 *invreq_amount,
1061 const u8 *invreq_features,
1062 const u64 *invreq_quantity,
1063 const struct pubkey *invreq_payer_id,
1064 const utf8 *invreq_payer_note,
1065 struct blinded_path **invreq_paths,
1066 struct bip_353_name *bip353,
1067 const u32 *invreq_recurrence_counter,
1068 const u32 *invreq_recurrence_start,
1069 const struct tlv_invoice_request_invreq_recurrence_cancel *invreq_recurrence_cancel)
1070{
1071 bool valid = true;
1072
1073 /* BOLT #12:
1074 * - MUST reject the invoice request if `invreq_payer_id` or `invreq_metadata` are not present.
1075 */
1076 if (invreq_metadata)
1077 json_add_hex_talarr(js, "invreq_metadata",
1078 invreq_metadata);
1079 else {
1080 json_add_string(js, "warning_missing_invreq_metadata",
1081 "invreq_metadata required");
1082 valid = false;
1083 }
1084
1085 /* This can be missing for an invoice though! */
1086 if (invreq_payer_id)
1087 json_add_pubkey(js, "invreq_payer_id", invreq_payer_id);
1088
1089 if (invreq_chain)
1090 json_add_sha256(js, "invreq_chain", &invreq_chain->shad.sha);
1091
1092 if (invreq_amount)
1093 json_add_amount_msat(js, "invreq_amount_msat",
1094 amount_msat(*invreq_amount));
1095 if (invreq_features)
1096 json_add_hex_talarr(js, "invreq_features", invreq_features);
1097 if (invreq_quantity)
1098 json_add_u64(js, "invreq_quantity", *invreq_quantity);
1099 if (invreq_payer_note)
1100 valid &= json_add_utf8(js, "invreq_payer_note", invreq_payer_note);
1101 if (invreq_paths)
1102 valid &= json_add_blinded_paths(cmd, js, "invreq_paths",
1103 invreq_paths, NULL);
1104
1105 if (bip353) {
1106 json_object_start(js, "invreq_bip_353_name");
1107 if (bip353->name) {
1108 json_add_str_fmt(js, "name", "%.*s",
1109 (int)tal_bytelen(bip353->name),
1110 (char *)bip353->name);
1111 }
1112 if (bip353->domain) {
1113 json_add_str_fmt(js, "domain", "%.*s",

Callers 2

json_add_invoice_requestFunction · 0.85
json_add_b12_invoiceFunction · 0.85

Calls 15

json_add_hex_talarrFunction · 0.85
json_add_pubkeyFunction · 0.85
json_add_sha256Function · 0.85
json_add_amount_msatFunction · 0.85
json_add_u64Function · 0.85
json_add_utf8Function · 0.85
json_add_blinded_pathsFunction · 0.85
json_object_startFunction · 0.85
json_add_str_fmtFunction · 0.85
tal_bytelenFunction · 0.85
json_object_endFunction · 0.85

Tested by

no test coverage detected