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

Function payment_start_at_blockheight

plugins/libplugin-pay.c:272–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270#define INVALID_BLOCKHEIGHT UINT32_MAX
271
272static
273void payment_start_at_blockheight(struct payment *p, u32 blockheight)
274{
275 struct payment *root = payment_root(p);
276
277 /* Should have been set in root payment, or propagated from root
278 * payment to all child payments. */
279 assert(p->local_id);
280
281 p->step = PAYMENT_STEP_INITIALIZED;
282 p->current_modifier = -1;
283
284 /* Pre-generate the getroute request, so modifiers can have their say,
285 * before we actually call `getroute` */
286 p->getroute->destination = p->destination;
287 p->getroute->max_hops = ROUTING_MAX_HOPS;
288 p->getroute->cltv = root->min_final_cltv_expiry;
289 p->getroute->amount = p->amount;
290
291 p->start_constraints = tal_dup(p, struct payment_constraints, &p->constraints);
292
293 if (blockheight != INVALID_BLOCKHEIGHT) {
294 /* The caller knows the actual blockheight. */
295 p->start_block = blockheight;
296 return payment_continue(p);
297 }
298 if (p->parent) {
299 /* The parent should have a start block. */
300 p->start_block = p->parent->start_block;
301 return payment_continue(p);
302 }
303
304 /* `waitblockheight 0` can be used as a query for the current
305 * block height.
306 * This is slightly better than `getinfo` since `getinfo`
307 * counts the channels and addresses and pushes more data
308 * onto the RPC but all we care about is the blockheight.
309 */
310 struct out_req *req;
311 req = jsonrpc_request_start(p->plugin, NULL, "waitblockheight",
312 &payment_getblockheight_success,
313 &payment_rpc_failure, p);
314 json_add_u32(req->js, "blockheight", 0);
315 send_outreq(p->plugin, req);
316}
317void payment_start(struct payment *p)
318{
319 payment_start_at_blockheight(p, INVALID_BLOCKHEIGHT);

Callers 2

payment_startFunction · 0.85
waitblockheight_rpc_cbFunction · 0.85

Calls 4

payment_rootFunction · 0.85
payment_continueFunction · 0.85
send_outreqFunction · 0.70
json_add_u32Function · 0.50

Tested by

no test coverage detected