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

Function handle_psbt_changed

lightningd/dual_open_control.c:3700–3769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3698}
3699
3700static void handle_psbt_changed(struct subd *dualopend,
3701 struct channel *channel,
3702 const u8 *msg)
3703{
3704 struct channel_id cid;
3705 u64 funding_serial;
3706 struct wally_psbt *psbt;
3707 struct json_stream *response;
3708 struct openchannel2_psbt_payload *payload;
3709 struct open_attempt *oa;
3710 struct command *cmd;
3711 struct channel_type *channel_type;
3712
3713 assert(channel->open_attempt);
3714 oa = channel->open_attempt;
3715 cmd = oa->cmd;
3716
3717 if (!fromwire_dualopend_psbt_changed(tmpctx, msg,
3718 &cid,
3719 &channel->req_confirmed_ins[REMOTE],
3720 &funding_serial,
3721 &psbt,
3722 &channel_type)) {
3723 channel_internal_error(channel,
3724 "Bad DUALOPEND_PSBT_CHANGED: %s",
3725 tal_hex(tmpctx, msg));
3726 return;
3727 }
3728
3729 /* This is often the first time we hear about channel details */
3730 tal_free(channel->type);
3731 channel->type = tal_steal(channel, channel_type);
3732
3733 switch (oa->role) {
3734 case TX_INITIATOR:
3735 if (!cmd) {
3736 channel_err_broken(channel,
3737 tal_fmt(tmpctx, "Unexpected"
3738 " PSBT_CHANGED %s",
3739 tal_hex(tmpctx, msg)));
3740 return;
3741 }
3742 /* This might be the first time we learn the channel_id */
3743 channel->cid = cid;
3744 response = json_stream_success(cmd);
3745 json_add_string(response, "channel_id",
3746 fmt_channel_id(tmpctx, &channel->cid));
3747 json_add_psbt(response, "psbt", psbt);
3748 json_add_channel_type(response, "channel_type", channel->type);
3749 json_add_bool(response, "commitments_secured", false);
3750 json_add_u64(response, "funding_serial", funding_serial);
3751 json_add_bool(response, "requires_confirmed_inputs",
3752 channel->req_confirmed_ins[REMOTE]);
3753
3754 oa->cmd = NULL;
3755 was_pending(command_success(cmd, response));
3756 return;
3757 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