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

Function json_openchannel_update

lightningd/dual_open_control.c:3179–3263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3177}
3178
3179static struct command_result *json_openchannel_update(struct command *cmd,
3180 const char *buffer,
3181 const jsmntok_t *obj UNNEEDED,
3182 const jsmntok_t *params)
3183{
3184 struct wally_psbt *psbt;
3185 struct channel_id *cid;
3186 struct channel *channel;
3187 struct psbt_validator *pv;
3188 struct command_result *ret;
3189 struct channel_inflight *inflight;
3190
3191 if (!param_check(cmd, buffer, params,
3192 p_req("channel_id", param_channel_id, &cid),
3193 p_req("psbt", param_psbt, &psbt),
3194 NULL))
3195 return command_param_failed();
3196
3197 channel = channel_by_cid(cmd->ld, cid);
3198 if (!channel)
3199 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
3200 "Unknown channel %s",
3201 fmt_channel_id(tmpctx, cid));
3202 if (!channel->owner)
3203 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
3204 "Peer not connected");
3205
3206
3207 if (!channel->open_attempt) {
3208 /* Check if the last inflight for this matches? */
3209 inflight = find_inprogress_inflight(channel, psbt);
3210 if (inflight) {
3211 return command_success(cmd,
3212 build_commit_response(cmd, channel, inflight));
3213 }
3214 return command_fail(cmd, FUNDING_STATE_INVALID,
3215 "Channel open not in progress");
3216 }
3217
3218 if (channel->open_attempt->cmd)
3219 return command_fail(cmd, FUNDING_STATE_INVALID,
3220 "Another openchannel command"
3221 " is in progress");
3222
3223 /* Add serials to PSBT */
3224 psbt_add_serials(psbt, TX_INITIATOR);
3225
3226 /* We require the PSBT to meet certain criteria such as
3227 * extra, proprietary fields (`serial_id`s) or
3228 * to have a `redeemscripts` iff the inputs are P2SH.
3229 *
3230 * Since this is externally provided, we confirm that
3231 * they've done the right thing / haven't lost any required info.
3232 */
3233 if (!psbt_has_required_fields(psbt))
3234 return command_fail(cmd, FUNDING_PSBT_INVALID,
3235 "PSBT is missing required fields %s",
3236 fmt_wally_psbt(tmpctx, psbt));

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
find_inprogress_inflightFunction · 0.85
build_commit_responseFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
fmt_wally_psbtFunction · 0.85
validate_input_unspentFunction · 0.85
command_param_failedFunction · 0.70
channel_by_cidFunction · 0.70
command_failFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected