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

Function psbt_funded

plugins/funder.c:294–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294static struct command_result *
295psbt_funded(struct command *cmd,
296 const char *buf,
297 const jsmntok_t *result,
298 struct open_info *info)
299{
300 struct wally_psbt *psbt;
301 struct json_stream *response;
302 struct amount_msat our_funding_msat;
303
304 const char *err;
305
306 err = json_scan(tmpctx, buf, result,
307 "{psbt:%}",
308 JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt));
309 if (err)
310 plugin_err(cmd->plugin,
311 "`fundpsbt` response did not scan %s: %.*s",
312 err, json_tok_full_len(result),
313 json_tok_full(buf, result));
314
315 /* We also mark all of our inputs as *ours*, so we
316 * can easily identify them for `signpsbt` later */
317 for (size_t i = 0; i < psbt->num_inputs; i++)
318 psbt_input_mark_ours(psbt, &psbt->inputs[i]);
319
320 new_channel_open(cmd->plugin, cmd->plugin,
321 info->id, info->cid, psbt);
322
323 if (!amount_sat_to_msat(&our_funding_msat, info->our_funding))
324 abort();
325
326 response = jsonrpc_stream_success(cmd);
327 json_add_string(response, "result", "continue");
328 json_add_psbt(response, "psbt", psbt);
329 json_add_amount_msat_only(response, "our_funding_msat",
330 our_funding_msat);
331
332 /* If we're accepting an lease request, *and* they've
333 * requested one, fill in our most recent infos */
334 if (current_policy->rates && !amount_sat_zero(info->requested_lease))
335 json_add_lease_rates(response, current_policy->rates);
336
337 return command_finished(cmd, response);
338}
339
340static struct command_result *
341psbt_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
amount_sat_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
json_tok_fullFunction · 0.50

Tested by

no test coverage detected