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

Function psbt_funded

plugins/funder.c:463–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463static struct command_result *
464psbt_funded(struct command *cmd,
465 const char *method,
466 const char *buf,
467 const jsmntok_t *result,
468 struct open_info *info)
469{
470 struct wally_psbt *psbt;
471 struct json_stream *response;
472 struct amount_msat our_funding_msat;
473
474 const char *err;
475
476 err = json_scan(tmpctx, buf, result,
477 "{psbt:%}",
478 JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt));
479 if (err)
480 plugin_err(cmd->plugin,
481 "`fundpsbt` response did not scan %s: %.*s",
482 err, json_tok_full_len(result),
483 json_tok_full(buf, result));
484
485 /* We also mark all of our inputs as *ours*, so we
486 * can easily identify them for `signpsbt` later */
487 for (size_t i = 0; i < psbt->num_inputs; i++)
488 psbt_input_mark_ours(psbt, &psbt->inputs[i]);
489
490 new_channel_open(cmd->plugin, cmd->plugin,
491 info->id, info->cid, psbt);
492
493 if (!amount_sat_to_msat(&our_funding_msat, info->our_funding))
494 abort();
495
496 response = jsonrpc_stream_success(cmd);
497 json_add_string(response, "result", "continue");
498 json_add_psbt(response, "psbt", psbt);
499 json_add_amount_msat(response, "our_funding_msat", our_funding_msat);
500
501 /* If we're accepting an lease request, *and* they've
502 * requested one, fill in our most recent infos */
503 if (current_policy->rates && !amount_sat_is_zero(info->requested_lease))
504 json_add_lease_rates(response, current_policy->rates);
505
506 funding_queue_done(info);
507 return command_finished(cmd, response);
508}
509
510static struct command_result *
511psbt_fund_failed(struct command *cmd,

Callers

nothing calls this directly

Calls 15

psbt_input_mark_oursFunction · 0.85
new_channel_openFunction · 0.85
abortFunction · 0.85
json_add_psbtFunction · 0.85
json_add_amount_msatFunction · 0.85
amount_sat_is_zeroFunction · 0.85
json_add_lease_ratesFunction · 0.85
funding_queue_doneFunction · 0.85
plugin_errFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_scanFunction · 0.50

Tested by

no test coverage detected