| 2936 | } |
| 2937 | |
| 2938 | static struct command_result *json_openchannel_update(struct command *cmd, |
| 2939 | const char *buffer, |
| 2940 | const jsmntok_t *obj UNNEEDED, |
| 2941 | const jsmntok_t *params) |
| 2942 | { |
| 2943 | struct wally_psbt *psbt; |
| 2944 | struct channel_id *cid; |
| 2945 | struct channel *channel; |
| 2946 | struct psbt_validator *pv; |
| 2947 | struct command_result *ret; |
| 2948 | struct channel_inflight *inflight; |
| 2949 | |
| 2950 | if (!param_check(cmd, buffer, params, |
| 2951 | p_req("channel_id", param_channel_id, &cid), |
| 2952 | p_req("psbt", param_psbt, &psbt), |
| 2953 | NULL)) |
| 2954 | return command_param_failed(); |
| 2955 | |
| 2956 | channel = channel_by_cid(cmd->ld, cid); |
| 2957 | if (!channel) |
| 2958 | return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL, |
| 2959 | "Unknown channel %s", |
| 2960 | fmt_channel_id(tmpctx, cid)); |
| 2961 | if (!channel->owner) |
| 2962 | return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, |
| 2963 | "Peer not connected"); |
| 2964 | |
| 2965 | |
| 2966 | if (!channel->open_attempt) { |
| 2967 | /* Check if the last inflight for this matches? */ |
| 2968 | inflight = find_inprogress_inflight(channel, psbt); |
| 2969 | if (inflight) { |
| 2970 | return command_success(cmd, |
| 2971 | build_commit_response(cmd, channel, inflight)); |
| 2972 | } |
| 2973 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2974 | "Channel open not in progress"); |
| 2975 | } |
| 2976 | |
| 2977 | if (channel->open_attempt->cmd) |
| 2978 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2979 | "Another openchannel command" |
| 2980 | " is in progress"); |
| 2981 | |
| 2982 | /* Add serials to PSBT */ |
| 2983 | psbt_add_serials(psbt, TX_INITIATOR); |
| 2984 | |
| 2985 | /* We require the PSBT to meet certain criteria such as |
| 2986 | * extra, proprietary fields (`serial_id`s) or |
| 2987 | * to have a `redeemscripts` iff the inputs are P2SH. |
| 2988 | * |
| 2989 | * Since this is externally provided, we confirm that |
| 2990 | * they've done the right thing / haven't lost any required info. |
| 2991 | */ |
| 2992 | if (!psbt_has_required_fields(psbt)) |
| 2993 | return command_fail(cmd, FUNDING_PSBT_INVALID, |
| 2994 | "PSBT is missing required fields %s", |
| 2995 | fmt_wally_psbt(tmpctx, psbt)); |
nothing calls this directly
no test coverage detected