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

Function json_invoice

lightningd/invoice.c:1135–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133}
1134
1135static struct command_result *json_invoice(struct command *cmd,
1136 const char *buffer,
1137 const jsmntok_t *obj UNNEEDED,
1138 const jsmntok_t *params)
1139{
1140 const jsmntok_t *fallbacks;
1141 struct amount_msat *msatoshi_val;
1142 struct invoice_info *info;
1143 const char *desc_val;
1144 const u8 **fallback_scripts = NULL;
1145 u64 *expiry;
1146 struct sha256 rhash;
1147 struct secret payment_secret;
1148 struct preimage *preimage;
1149 u32 *cltv;
1150 struct jsonrpc_request *req;
1151 struct plugin *plugin;
1152 bool *hashonly;
1153#if DEVELOPER
1154 const jsmntok_t *routes;
1155#endif
1156
1157 info = tal(cmd, struct invoice_info);
1158 info->cmd = cmd;
1159
1160 if (!param(cmd, buffer, params,
1161 p_req("amount_msat|msatoshi", param_positive_msat_or_any, &msatoshi_val),
1162 p_req("label", param_label, &info->label),
1163 p_req("description", param_escaped_string, &desc_val),
1164 p_opt_def("expiry", param_time, &expiry, 3600*24*7),
1165 p_opt("fallbacks", param_array, &fallbacks),
1166 p_opt("preimage", param_preimage, &preimage),
1167 p_opt("exposeprivatechannels", param_chanhints,
1168 &info->chanhints),
1169 p_opt_def("cltv", param_number, &cltv,
1170 cmd->ld->config.cltv_final),
1171 p_opt_def("deschashonly", param_bool, &hashonly, false),
1172#if DEVELOPER
1173 p_opt("dev-routes", param_array, &routes),
1174#endif
1175 NULL))
1176 return command_param_failed();
1177
1178 if (strlen(info->label->s) > INVOICE_MAX_LABEL_LEN) {
1179 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1180 "Label '%s' over %u bytes", info->label->s,
1181 INVOICE_MAX_LABEL_LEN);
1182 }
1183
1184 if (strlen(desc_val) > BOLT11_FIELD_BYTE_LIMIT && !*hashonly) {
1185 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1186 "Descriptions greater than %d bytes "
1187 "not yet supported "
1188 "(description length %zu)",
1189 BOLT11_FIELD_BYTE_LIMIT,
1190 strlen(desc_val));
1191 }
1192

Callers

nothing calls this directly

Calls 15

invoice_secretFunction · 0.85
time_nowFunction · 0.85
unpack_routesFunction · 0.85
invoice_completeFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
parse_fallbackFunction · 0.70
sha256Class · 0.70
command_logFunction · 0.70
jsonrpc_request_endFunction · 0.70
find_plugin_for_commandFunction · 0.70
plugin_request_sendFunction · 0.70

Tested by

no test coverage detected