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

Function payment_start_at_blockheight

plugins/libplugin-pay.c:333–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331#define INVALID_BLOCKHEIGHT UINT32_MAX
332
333static struct command_result *
334payment_start_at_blockheight(struct payment *p, u32 blockheight)
335{
336 struct payment *root = payment_root(p);
337
338 /* Should have been set in root payment, or propagated from root
339 * payment to all child payments. */
340 assert(p->local_id);
341
342 p->step = PAYMENT_STEP_INITIALIZED;
343 p->current_modifier = -1;
344
345 /* Pre-generate the getroute request, so modifiers can have their say,
346 * before we actually call `getroute` */
347 p->getroute->destination = p->route_destination;
348 p->getroute->max_hops = ROUTING_MAX_HOPS;
349 p->getroute->cltv = root->min_final_cltv_expiry;
350 p->getroute->amount = p->our_amount;
351
352 p->start_constraints = tal_dup(p, struct payment_constraints, &p->constraints);
353
354 if (blockheight != INVALID_BLOCKHEIGHT) {
355 /* The caller knows the actual blockheight. */
356 p->start_block = blockheight;
357 return payment_continue(p);
358 }
359 if (p->parent) {
360 /* The parent should have a start block. */
361 p->start_block = p->parent->start_block;
362 return payment_continue(p);
363 }
364
365 /* Check with the backend what it believes the network's
366 * height to be. We'll base all of our offsets based on that
367 * height, allowing us to send while still syncing.
368 */
369 struct out_req *req;
370 req = jsonrpc_request_start(payment_cmd(p), "getchaininfo",
371 &payment_getblockheight_success,
372 &payment_rpc_failure, p);
373 json_add_u32(req->js, "last_height", 0);
374 return send_outreq(req);
375}
376
377void payment_start(struct payment *p)
378{

Callers 1

payment_startFunction · 0.85

Calls 5

payment_rootFunction · 0.85
payment_cmdFunction · 0.85
json_add_u32Function · 0.85
payment_continueFunction · 0.70
send_outreqFunction · 0.70

Tested by

no test coverage detected