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

Function json_openchannel_signed

lightningd/dual_open_control.c:2966–3089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2964}
2965
2966static struct command_result *
2967json_openchannel_signed(struct command *cmd,
2968 const char *buffer,
2969 const jsmntok_t *obj UNNEEDED,
2970 const jsmntok_t *params)
2971{
2972 struct wally_psbt *psbt;
2973 struct channel_id *cid;
2974 struct channel *channel;
2975 struct bitcoin_txid txid;
2976 struct channel_inflight *inflight;
2977
2978 if (!param_check(cmd, buffer, params,
2979 p_req("channel_id", param_channel_id, &cid),
2980 p_req("signed_psbt", param_psbt, &psbt),
2981 NULL))
2982 return command_param_failed();
2983
2984 channel = channel_by_cid(cmd->ld, cid);
2985 if (!channel)
2986 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
2987 "Unknown channel");
2988 if (channel->open_attempt)
2989 return command_fail(cmd, FUNDING_STATE_INVALID,
2990 "Commitments for this channel not "
2991 "yet secured, see `openchannel_update`");
2992
2993 if (list_empty(&channel->inflights))
2994 return command_fail(cmd, FUNDING_STATE_INVALID,
2995 "Channel open not initialized yet.");
2996
2997 if (channel->openchannel_signed_cmd)
2998 return command_fail(cmd, FUNDING_STATE_INVALID,
2999 "Already sent sigs, waiting for peer's");
3000
3001 /* Verify that the psbt's txid matches that of the
3002 * funding txid for this channel */
3003 psbt_txid(NULL, psbt, &txid, NULL);
3004 if (!bitcoin_txid_eq(&txid, &channel->funding.txid))
3005 return command_fail(cmd, FUNDING_PSBT_INVALID,
3006 "Txid for passed in PSBT does not match"
3007 " funding txid for channel. Expected %s, "
3008 "received %s",
3009 fmt_bitcoin_txid(tmpctx,
3010 &channel->funding.txid),
3011 fmt_bitcoin_txid(tmpctx,
3012 &txid));
3013
3014 inflight = list_tail(&channel->inflights,
3015 struct channel_inflight,
3016 list);
3017 if (!inflight)
3018 return command_fail(cmd, LIGHTNINGD,
3019 "Open attempt for channel not found");
3020
3021 if (!bitcoin_txid_eq(&txid, &inflight->funding->outpoint.txid))
3022 return command_fail(cmd, LIGHTNINGD,
3023 "Current inflight transaction is %s,"

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
psbt_txidFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
psbt_is_finalizedFunction · 0.85
psbt_finalizeFunction · 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
clone_psbtFunction · 0.85
command_param_failedFunction · 0.70

Tested by

no test coverage detected