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

Function handle_psbt_changed

lightningd/dual_open_control.c:3419–3488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3417}
3418
3419static void handle_psbt_changed(struct subd *dualopend,
3420 struct channel *channel,
3421 const u8 *msg)
3422{
3423 struct channel_id cid;
3424 u64 funding_serial;
3425 struct wally_psbt *psbt;
3426 struct json_stream *response;
3427 struct openchannel2_psbt_payload *payload;
3428 struct open_attempt *oa;
3429 struct command *cmd;
3430 struct channel_type *channel_type;
3431
3432 assert(channel->open_attempt);
3433 oa = channel->open_attempt;
3434 cmd = oa->cmd;
3435
3436 if (!fromwire_dualopend_psbt_changed(tmpctx, msg,
3437 &cid,
3438 &channel->req_confirmed_ins[REMOTE],
3439 &funding_serial,
3440 &psbt,
3441 &channel_type)) {
3442 channel_internal_error(channel,
3443 "Bad DUALOPEND_PSBT_CHANGED: %s",
3444 tal_hex(tmpctx, msg));
3445 return;
3446 }
3447
3448 /* This is often the first time we hear about channel details */
3449 tal_free(channel->type);
3450 channel->type = tal_steal(channel, channel_type);
3451
3452 switch (oa->role) {
3453 case TX_INITIATOR:
3454 if (!cmd) {
3455 channel_err_broken(channel,
3456 tal_fmt(tmpctx, "Unexpected"
3457 " PSBT_CHANGED %s",
3458 tal_hex(tmpctx, msg)));
3459 return;
3460 }
3461 /* This might be the first time we learn the channel_id */
3462 channel->cid = cid;
3463 response = json_stream_success(cmd);
3464 json_add_string(response, "channel_id",
3465 fmt_channel_id(tmpctx, &channel->cid));
3466 json_add_psbt(response, "psbt", psbt);
3467 json_add_channel_type(response, "channel_type", channel->type);
3468 json_add_bool(response, "commitments_secured", false);
3469 json_add_u64(response, "funding_serial", funding_serial);
3470 json_add_bool(response, "requires_confirmed_inputs",
3471 channel->req_confirmed_ins[REMOTE]);
3472
3473 oa->cmd = NULL;
3474 was_pending(command_success(cmd, response));
3475 return;
3476 case TX_ACCEPTER:

Callers 1

dual_opend_msgFunction · 0.85

Calls 14

tal_hexFunction · 0.85
tal_freeFunction · 0.85
channel_err_brokenFunction · 0.85
json_add_psbtFunction · 0.85
json_add_channel_typeFunction · 0.85
json_add_boolFunction · 0.85
json_add_u64Function · 0.85
abortFunction · 0.85
channel_internal_errorFunction · 0.70
json_stream_successFunction · 0.70
was_pendingFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected