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

Function build_commit_response

lightningd/dual_open_control.c:3193–3222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3191}
3192
3193static struct json_stream *build_commit_response(struct command *cmd,
3194 struct channel *channel,
3195 struct channel_inflight *inflight)
3196{
3197 struct json_stream *response;
3198
3199 response = json_stream_success(cmd);
3200 json_add_string(response, "channel_id",
3201 fmt_channel_id(tmpctx, &channel->cid));
3202 json_add_psbt(response, "psbt", inflight->funding_psbt);
3203 json_add_channel_type(response, "channel_type", channel->type);
3204 json_add_bool(response, "commitments_secured", inflight->last_tx != NULL);
3205 /* For convenience sake, we include the funding outnum */
3206 assert(inflight->funding);
3207 json_add_num(response, "funding_outnum", inflight->funding->outpoint.n);
3208 /* This is *sort of* dicey, since there's a small chance the channel
3209 * might disconnect/reconnect and we lose the open-attempt data */
3210 if (channel->open_attempt && channel->open_attempt->our_upfront_shutdown_script) {
3211 /* FIXME: also include the output as address */
3212 json_add_hex_talarr(response, "close_to",
3213 channel->open_attempt->our_upfront_shutdown_script);
3214 /* Worse case is that we accidentally report what we're 'closing-to' even if you
3215 * didn't request it? We *could* just announce it every time... */
3216 } else if (!channel->open_attempt && channel->shutdown_scriptpubkey[LOCAL]) {
3217 json_add_hex_talarr(response, "close_to",
3218 channel->shutdown_scriptpubkey[LOCAL]);
3219 /* FIXME: also include the output as address */
3220 }
3221 return response;
3222}
3223
3224static struct command_result *json_openchannel_update(struct command *cmd,
3225 const char *buffer,

Callers 2

json_openchannel_updateFunction · 0.85
handle_commit_receivedFunction · 0.85

Calls 8

json_add_psbtFunction · 0.85
json_add_channel_typeFunction · 0.85
json_add_boolFunction · 0.85
json_add_numFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_stream_successFunction · 0.70
json_add_stringFunction · 0.50
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected