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

Function json_pay

plugins/pay.c:973–1230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

971}
972
973static struct command_result *json_pay(struct command *cmd,
974 const char *buf,
975 const jsmntok_t *params)
976{
977 struct payment *p;
978 const char *b11str;
979 struct bolt11 *b11;
980 char *b11_fail, *b12_fail;
981 u64 *maxfee_pct_millionths;
982 u32 *maxdelay;
983 struct amount_msat *exemptfee, *msat, *maxfee;
984 const char *label, *description;
985 unsigned int *retryfor;
986 u64 *riskfactor_millionths;
987 struct shadow_route_data *shadow_route;
988 struct amount_msat *invmsat;
989 u64 invexpiry;
990 struct sha256 *local_offer_id;
991 const struct tlv_invoice *b12;
992 struct out_req *req;
993 struct route_exclusion **exclusions;
994#if DEVELOPER
995 bool *use_shadow;
996#endif
997
998 /* If any of the modifiers need to add params to the JSON-RPC call we
999 * would add them to the `param()` call below, and have them be
1000 * initialized directly that way. */
1001 if (!param(cmd, buf, params,
1002 /* FIXME: parameter should be invstring now */
1003 p_req("bolt11", param_string, &b11str),
1004 p_opt("amount_msat|msatoshi", param_msat, &msat),
1005 p_opt("label", param_string, &label),
1006 p_opt_def("riskfactor", param_millionths,
1007 &riskfactor_millionths, 10000000),
1008 p_opt("maxfeepercent", param_millionths,
1009 &maxfee_pct_millionths),
1010 p_opt_def("retry_for", param_number, &retryfor, 60),
1011 p_opt_def("maxdelay", param_number, &maxdelay,
1012 maxdelay_default),
1013 p_opt("exemptfee", param_msat, &exemptfee),
1014 p_opt("localofferid", param_sha256, &local_offer_id),
1015 p_opt("exclude", param_route_exclusion_array, &exclusions),
1016 p_opt("maxfee", param_msat, &maxfee),
1017 p_opt("description", param_string, &description),
1018#if DEVELOPER
1019 p_opt_def("use_shadow", param_bool, &use_shadow, true),
1020#endif
1021 NULL))
1022 return command_param_failed();
1023
1024 p = payment_new(cmd, cmd, NULL /* No parent */, paymod_mods);
1025 p->invstring = tal_steal(p, b11str);
1026 p->description = tal_steal(p, description);
1027
1028 if (!bolt12_has_prefix(b11str)) {
1029 b11 =
1030 bolt11_decode(tmpctx, b11str, plugin_feature_set(cmd->plugin),

Callers

nothing calls this directly

Calls 15

payment_newFunction · 0.85
bolt12_has_prefixFunction · 0.85
plugin_feature_setFunction · 0.85
gossmap_guess_node_idFunction · 0.85
time_nowFunction · 0.85
tal_freeFunction · 0.85
node_id_eqFunction · 0.85
timeabs_addFunction · 0.85
time_from_secFunction · 0.85
amount_msat_feeFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70

Tested by

no test coverage detected