| 2504 | |
| 2505 | |
| 2506 | static struct command_result *json_openchannel_update(struct command *cmd, |
| 2507 | const char *buffer, |
| 2508 | const jsmntok_t *obj UNNEEDED, |
| 2509 | const jsmntok_t *params) |
| 2510 | { |
| 2511 | struct wally_psbt *psbt; |
| 2512 | struct channel_id *cid; |
| 2513 | struct channel *channel; |
| 2514 | u8 *msg; |
| 2515 | |
| 2516 | if (!param(cmd, buffer, params, |
| 2517 | p_req("channel_id", param_channel_id, &cid), |
| 2518 | p_req("psbt", param_psbt, &psbt), |
| 2519 | NULL)) |
| 2520 | return command_param_failed(); |
| 2521 | |
| 2522 | channel = channel_by_cid(cmd->ld, cid); |
| 2523 | if (!channel) |
| 2524 | return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL, |
| 2525 | "Unknown channel %s", |
| 2526 | type_to_string(tmpctx, struct channel_id, |
| 2527 | cid)); |
| 2528 | if (!channel->owner) |
| 2529 | return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, |
| 2530 | "Peer not connected"); |
| 2531 | |
| 2532 | if (!channel->open_attempt) |
| 2533 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2534 | "Channel open not in progress"); |
| 2535 | |
| 2536 | if (channel->open_attempt->cmd) |
| 2537 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2538 | "Another openchannel command" |
| 2539 | " is in progress"); |
| 2540 | |
| 2541 | /* Add serials to PSBT */ |
| 2542 | psbt_add_serials(psbt, TX_INITIATOR); |
| 2543 | |
| 2544 | /* We require the PSBT to meet certain criteria such as |
| 2545 | * extra, proprietary fields (`serial_id`s) or |
| 2546 | * to have a `redeemscripts` iff the inputs are P2SH. |
| 2547 | * |
| 2548 | * Since this is externally provided, we confirm that |
| 2549 | * they've done the right thing / haven't lost any required info. |
| 2550 | */ |
| 2551 | if (!psbt_has_required_fields(psbt)) |
| 2552 | return command_fail(cmd, FUNDING_PSBT_INVALID, |
| 2553 | "PSBT is missing required fields %s", |
| 2554 | type_to_string(tmpctx, struct wally_psbt, |
| 2555 | psbt)); |
| 2556 | |
| 2557 | channel->open_attempt->cmd = cmd; |
| 2558 | |
| 2559 | msg = towire_dualopend_psbt_updated(NULL, psbt); |
| 2560 | subd_send_msg(channel->owner, take(msg)); |
| 2561 | return command_still_pending(cmd); |
| 2562 | } |
| 2563 |
nothing calls this directly
no test coverage detected