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

Function json_openchannel2_sign_call

plugins/funder.c:284–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284static struct command_result *
285json_openchannel2_sign_call(struct command *cmd,
286 const char *buf,
287 const jsmntok_t *params)
288{
289 struct channel_id cid;
290 struct wally_psbt *psbt;
291 const char *err;
292 struct out_req *req;
293 struct pending_open *open;
294 size_t count;
295
296 err = json_scan(tmpctx, buf, params,
297 "{openchannel2_sign:"
298 "{channel_id:%,psbt:%}}",
299 JSON_SCAN(json_to_channel_id, &cid),
300 JSON_SCAN_TAL(cmd, json_to_psbt, &psbt));
301
302 if (err)
303 plugin_err(cmd->plugin,
304 "`openchannel2_sign` payload did not scan %s: %.*s",
305 err, json_tok_full_len(params),
306 json_tok_full(buf, params));
307
308 /* If we're not tracking this open, just pass through */
309 open = find_channel_pending_open(&cid);
310 if (!open) {
311 plugin_log(cmd->plugin, LOG_DBG,
312 "nothing to sign for channel %s",
313 fmt_channel_id(tmpctx, &cid));
314 return command_hook_cont_psbt(cmd, psbt);
315 }
316
317 if (!psbt_has_our_input(psbt)) {
318 plugin_log(cmd->plugin, LOG_DBG,
319 "no inputs to sign for channel %s",
320 fmt_channel_id(tmpctx, &cid));
321 return command_hook_cont_psbt(cmd, psbt);
322 }
323
324 plugin_log(cmd->plugin, LOG_DBG,
325 "openchannel_sign PSBT is %s",
326 fmt_wally_psbt(tmpctx, psbt));
327
328 req = jsonrpc_request_start(cmd,
329 "signpsbt",
330 &signpsbt_done,
331 &forward_error,
332 open);
333 json_add_psbt(req->js, "psbt", psbt);
334 /* Use input markers to identify which inputs
335 * are ours, only sign those */
336 json_array_start(req->js, "signonly");
337 count = 0;
338 for (size_t i = 0; i < psbt->num_inputs; i++) {
339 if (psbt_input_is_ours(&psbt->inputs[i])) {
340 json_add_num(req->js, NULL, i);
341 count++;

Callers

nothing calls this directly

Calls 15

command_hook_cont_psbtFunction · 0.85
psbt_has_our_inputFunction · 0.85
fmt_wally_psbtFunction · 0.85
json_add_psbtFunction · 0.85
json_array_startFunction · 0.85
psbt_input_is_oursFunction · 0.85
json_add_numFunction · 0.85
json_array_endFunction · 0.85
plugin_errFunction · 0.70
plugin_logFunction · 0.70
send_outreqFunction · 0.70

Tested by

no test coverage detected