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

Function waitblockheight_rpc_cb

plugins/libplugin-pay.c:3310–3354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3308 direct_pay_cb);
3309
3310static struct command_result *waitblockheight_rpc_cb(struct command *cmd,
3311 const char *buffer,
3312 const jsmntok_t *toks,
3313 struct payment *p)
3314{
3315 const jsmntok_t *blockheighttok, *codetok;
3316
3317 u32 blockheight;
3318 int code;
3319 struct payment *subpayment;
3320
3321 blockheighttok = json_get_member(buffer, toks, "blockheight");
3322
3323 if (!blockheighttok ||
3324 !json_to_number(buffer, blockheighttok, &blockheight)) {
3325 codetok = json_get_member(buffer, toks, "code");
3326 json_to_int(buffer, codetok, &code);
3327 if (code == WAIT_TIMEOUT) {
3328 payment_fail(
3329 p,
3330 "Timed out while attempting to sync to blockheight "
3331 "returned by destination. Please finish syncing "
3332 "with the blockchain and try again.");
3333
3334 } else {
3335 plugin_err(
3336 p->plugin,
3337 "Unexpected result from waitblockheight: %.*s",
3338 json_tok_full_len(toks),
3339 json_tok_full(buffer, toks));
3340 }
3341 } else {
3342 subpayment = payment_new(p, NULL, p, p->modifiers);
3343 payment_start_at_blockheight(subpayment, blockheight);
3344 payment_set_step(p, PAYMENT_STEP_RETRY);
3345 subpayment->why = tal_fmt(
3346 subpayment, "Retrying after waiting for blockchain sync.");
3347 paymod_log(
3348 p, LOG_DBG,
3349 "Retrying after waitblockheight, new partid %" PRIu32,
3350 subpayment->partid);
3351 payment_continue(p);
3352 }
3353 return command_still_pending(cmd);
3354}
3355
3356static void waitblockheight_cb(void *d, struct payment *p)
3357{

Callers

nothing calls this directly

Calls 13

payment_failFunction · 0.85
payment_newFunction · 0.85
payment_set_stepFunction · 0.85
paymod_logFunction · 0.85
payment_continueFunction · 0.85
plugin_errFunction · 0.70
command_still_pendingFunction · 0.70
json_get_memberFunction · 0.50
json_to_numberFunction · 0.50
json_to_intFunction · 0.50
json_tok_full_lenFunction · 0.50

Tested by

no test coverage detected