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

Function json_openchannel_update

lightningd/dual_open_control.c:3224–3308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3222}
3223
3224static struct command_result *json_openchannel_update(struct command *cmd,
3225 const char *buffer,
3226 const jsmntok_t *obj UNNEEDED,
3227 const jsmntok_t *params)
3228{
3229 struct wally_psbt *psbt;
3230 struct channel_id *cid;
3231 struct channel *channel;
3232 struct psbt_validator *pv;
3233 struct command_result *ret;
3234 struct channel_inflight *inflight;
3235
3236 if (!param_check(cmd, buffer, params,
3237 p_req("channel_id", param_channel_id, &cid),
3238 p_req("psbt", param_psbt, &psbt),
3239 NULL))
3240 return command_param_failed();
3241
3242 channel = channel_by_cid(cmd->ld, cid);
3243 if (!channel)
3244 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
3245 "Unknown channel %s",
3246 fmt_channel_id(tmpctx, cid));
3247 if (!channel->owner)
3248 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
3249 "Peer not connected");
3250
3251
3252 if (!channel->open_attempt) {
3253 /* Check if the last inflight for this matches? */
3254 inflight = find_inprogress_inflight(channel, psbt);
3255 if (inflight) {
3256 return command_success(cmd,
3257 build_commit_response(cmd, channel, inflight));
3258 }
3259 return command_fail(cmd, FUNDING_STATE_INVALID,
3260 "Channel open not in progress");
3261 }
3262
3263 if (channel->open_attempt->cmd)
3264 return command_fail(cmd, FUNDING_STATE_INVALID,
3265 "Another openchannel command"
3266 " is in progress");
3267
3268 /* Add serials to PSBT */
3269 psbt_add_serials(psbt, TX_INITIATOR);
3270
3271 /* We require the PSBT to meet certain criteria such as
3272 * extra, proprietary fields (`serial_id`s) or
3273 * to have a `redeemscripts` iff the inputs are P2SH.
3274 *
3275 * Since this is externally provided, we confirm that
3276 * they've done the right thing / haven't lost any required info.
3277 */
3278 if (!psbt_has_required_fields(psbt))
3279 return command_fail(cmd, FUNDING_PSBT_INVALID,
3280 "PSBT is missing required fields %s",
3281 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