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

Function json_keysend

plugins/keysend.c:179–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179static struct command_result *json_keysend(struct command *cmd, const char *buf,
180 const jsmntok_t *params)
181{
182 struct payment *p;
183 const char *label;
184 struct amount_msat *exemptfee, *msat, *maxfee;
185 struct node_id *destination;
186 u64 *maxfee_pct_millionths;
187 u32 *maxdelay;
188 unsigned int *retryfor;
189 struct route_info **hints;
190 struct tlv_field *extra_fields;
191 bool *dev_use_shadow;
192 struct out_req *req;
193
194 /* BOLT #4:
195 * ## `max_htlc_cltv` Selection
196 *
197 * This ... value is defined as 2016 blocks, based on historical value
198 * deployed by Lightning implementations.
199 */
200 /* FIXME: Typo in spec for CLTV in descripton! But it breaks our spelling check, so we omit it above */
201 if (!param_check(cmd, buf, params,
202 p_req("destination", param_node_id, &destination),
203 p_req("amount_msat", param_msat, &msat),
204 p_opt("label", param_string, &label),
205 p_opt("maxfeepercent", param_millionths,
206 &maxfee_pct_millionths),
207 p_opt_def("retry_for", param_number, &retryfor, 60),
208 p_opt_def("maxdelay", param_number, &maxdelay, 2016),
209 p_opt("exemptfee", param_msat, &exemptfee),
210 p_opt("extratlvs", param_extra_tlvs, &extra_fields),
211 p_opt("routehints", param_routehint_array, &hints),
212 p_opt("maxfee", param_msat, &maxfee),
213 p_opt_dev("dev_use_shadow", param_bool, &dev_use_shadow, true),
214 NULL))
215 return command_param_failed();
216
217 p = payment_new(cmd, cmd, NULL /* No parent */, global_hints, pay_mods);
218 p->local_id = &my_id;
219 p->route_destination = tal_steal(p, destination);
220 p->pay_destination = p->route_destination;
221 p->payment_secret = NULL;
222 p->payment_metadata = NULL;
223 p->blindedpath = NULL;
224 p->blindedpay = NULL;
225 /* FIXME: We could allow partial keysends, too, but we'd have to allow
226 * caller to provide keysend secret */
227 p->our_amount = p->final_amount = *msat;
228 p->routes = tal_steal(p, hints);
229 // 42 is the Rust-Lightning default and the highest minimum we know of.
230 p->min_final_cltv_expiry = 42;
231 p->features = NULL;
232 p->invstring = NULL;
233 /* Don't try to use invstring to hand to sendonion! */
234 p->invstring_used = true;
235 p->why = "Initial attempt";
236 p->constraints.cltv_budget = *maxdelay;

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
timemono_addFunction · 0.85
time_monoFunction · 0.85
time_from_secFunction · 0.85
node_id_eqFunction · 0.85
amount_msat_feeFunction · 0.85
json_add_node_idFunction · 0.85
json_add_sha256Function · 0.85
json_add_amount_msatFunction · 0.85
command_param_failedFunction · 0.70
payment_newFunction · 0.70
command_failFunction · 0.70

Tested by

no test coverage detected