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

Function json_openchannel_signed

lightningd/dual_open_control.c:2394–2503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2392}
2393
2394static struct command_result *
2395json_openchannel_signed(struct command *cmd,
2396 const char *buffer,
2397 const jsmntok_t *obj UNNEEDED,
2398 const jsmntok_t *params)
2399{
2400 struct wally_psbt *psbt;
2401 struct channel_id *cid;
2402 struct channel *channel;
2403 struct bitcoin_txid txid;
2404 struct channel_inflight *inflight;
2405
2406 if (!param(cmd, buffer, params,
2407 p_req("channel_id", param_channel_id, &cid),
2408 p_req("signed_psbt", param_psbt, &psbt),
2409 NULL))
2410 return command_param_failed();
2411
2412 channel = channel_by_cid(cmd->ld, cid);
2413 if (!channel)
2414 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
2415 "Unknown channel");
2416 if (!channel->owner)
2417 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
2418 "Peer not connected");
2419
2420 if (channel->open_attempt)
2421 return command_fail(cmd, FUNDING_STATE_INVALID,
2422 "Commitments for this channel not "
2423 "yet secured, see `openchannel_update`");
2424
2425 if (list_empty(&channel->inflights))
2426 return command_fail(cmd, FUNDING_STATE_INVALID,
2427 "Channel open not initialized yet.");
2428
2429 if (channel->openchannel_signed_cmd)
2430 return command_fail(cmd, FUNDING_STATE_INVALID,
2431 "Already sent sigs, waiting for peer's");
2432
2433 /* Verify that the psbt's txid matches that of the
2434 * funding txid for this channel */
2435 psbt_txid(NULL, psbt, &txid, NULL);
2436 if (!bitcoin_txid_eq(&txid, &channel->funding.txid))
2437 return command_fail(cmd, FUNDING_PSBT_INVALID,
2438 "Txid for passed in PSBT does not match"
2439 " funding txid for channel. Expected %s, "
2440 "received %s",
2441 type_to_string(tmpctx, struct bitcoin_txid,
2442 &channel->funding.txid),
2443 type_to_string(tmpctx, struct bitcoin_txid,
2444 &txid));
2445
2446 inflight = list_tail(&channel->inflights,
2447 struct channel_inflight,
2448 list);
2449 if (!inflight)
2450 return command_fail(cmd, LIGHTNINGD,
2451 "Open attempt for channel not found");

Callers

nothing calls this directly

Calls 15

channel_by_cidFunction · 0.85
psbt_txidFunction · 0.85
psbt_is_finalizedFunction · 0.85
psbt_side_finalizedFunction · 0.85
tal_wally_startFunction · 0.85
tal_wally_endFunction · 0.85
tal_freeFunction · 0.85
wallet_inflight_saveFunction · 0.85
channel_watch_fundingFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected