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

Function json_openchannel_update

lightningd/dual_open_control.c:2506–2562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2504
2505
2506static 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

Callers

nothing calls this directly

Calls 9

channel_by_cidFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
subd_send_msgFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected