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