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

Function psbt_funded

plugins/funder.c:424–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424static struct command_result *
425psbt_funded(struct command *cmd,
426 const char *method,
427 const char *buf,
428 const jsmntok_t *result,
429 struct open_info *info)
430{
431 struct wally_psbt *psbt;
432 struct json_stream *response;
433 struct amount_msat our_funding_msat;
434
435 const char *err;
436
437 err = json_scan(tmpctx, buf, result,
438 "{psbt:%}",
439 JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt));
440 if (err)
441 plugin_err(cmd->plugin,
442 "`fundpsbt` response did not scan %s: %.*s",
443 err, json_tok_full_len(result),
444 json_tok_full(buf, result));
445
446 /* We also mark all of our inputs as *ours*, so we
447 * can easily identify them for `signpsbt` later */
448 for (size_t i = 0; i < psbt->num_inputs; i++)
449 psbt_input_mark_ours(psbt, &psbt->inputs[i]);
450
451 new_channel_open(cmd->plugin, cmd->plugin,
452 info->id, info->cid, psbt);
453
454 if (!amount_sat_to_msat(&our_funding_msat, info->our_funding))
455 abort();
456
457 response = jsonrpc_stream_success(cmd);
458 json_add_string(response, "result", "continue");
459 json_add_psbt(response, "psbt", psbt);
460 json_add_amount_msat(response, "our_funding_msat", our_funding_msat);
461
462 /* If we're accepting an lease request, *and* they've
463 * requested one, fill in our most recent infos */
464 if (current_policy->rates && !amount_sat_is_zero(info->requested_lease))
465 json_add_lease_rates(response, current_policy->rates);
466
467 return command_finished(cmd, response);
468}
469
470static struct command_result *
471psbt_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
plugin_errFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_scanFunction · 0.50
json_tok_full_lenFunction · 0.50

Tested by

no test coverage detected