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

Function json_keysend

plugins/keysend.c:136–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134};
135
136static struct command_result *json_keysend(struct command *cmd, const char *buf,
137 const jsmntok_t *params)
138{
139 struct payment *p;
140 const char *label;
141 struct amount_msat *exemptfee, *msat;
142 struct node_id *destination;
143 u64 *maxfee_pct_millionths;
144 u32 *maxdelay;
145 unsigned int *retryfor;
146 struct route_info **hints;
147 struct tlv_field *extra_fields;
148
149#if DEVELOPER
150 bool *use_shadow;
151#endif
152 if (!param(cmd, buf, params,
153 p_req("destination", param_node_id, &destination),
154 p_req("amount_msat|msatoshi", param_msat, &msat),
155 p_opt("label", param_string, &label),
156 p_opt_def("maxfeepercent", param_millionths,
157 &maxfee_pct_millionths, 500000),
158 p_opt_def("retry_for", param_number, &retryfor, 60),
159 p_opt_def("maxdelay", param_number, &maxdelay,
160 maxdelay_default),
161 p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
162 p_opt("extratlvs", param_extra_tlvs, &extra_fields),
163 p_opt("routehints", param_routehint_array, &hints),
164#if DEVELOPER
165 p_opt_def("use_shadow", param_bool, &use_shadow, true),
166#endif
167 NULL))
168 return command_param_failed();
169
170 p = payment_new(cmd, cmd, NULL /* No parent */, pay_mods);
171 p->local_id = &my_id;
172 p->json_buffer = tal_dup_talarr(p, const char, buf);
173 p->json_toks = params;
174 p->destination = tal_steal(p, destination);
175 p->payment_secret = NULL;
176 p->payment_metadata = NULL;
177 p->amount = *msat;
178 p->routes = tal_steal(p, hints);
179 // 22 is the Rust-Lightning default and the highest minimum we know of.
180 p->min_final_cltv_expiry = 22;
181 p->features = NULL;
182 p->invstring = NULL;
183 /* Don't try to use invstring to hand to sendonion! */
184 p->invstring_used = true;
185 p->why = "Initial attempt";
186 p->constraints.cltv_budget = *maxdelay;
187 p->deadline = timeabs_add(time_now(), time_from_sec(*retryfor));
188 p->getroute->riskfactorppm = 10000000;
189
190 if (node_id_eq(&my_id, p->destination)) {
191 return command_fail(
192 cmd, JSONRPC2_INVALID_PARAMS,
193 "We are the destination. Keysend cannot be used to send funds to yourself");

Callers

nothing calls this directly

Calls 11

payment_newFunction · 0.85
timeabs_addFunction · 0.85
time_nowFunction · 0.85
time_from_secFunction · 0.85
node_id_eqFunction · 0.85
amount_msat_feeFunction · 0.85
payment_startFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected