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

Function handle_psbt_changed

lightningd/dual_open_control.c:2805–2866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2803}
2804
2805static void handle_psbt_changed(struct subd *dualopend,
2806 struct channel *channel,
2807 const u8 *msg)
2808{
2809 struct channel_id cid;
2810 u64 funding_serial;
2811 struct wally_psbt *psbt;
2812 struct json_stream *response;
2813 struct openchannel2_psbt_payload *payload;
2814 struct open_attempt *oa;
2815 struct command *cmd;
2816
2817 assert(channel->open_attempt);
2818 oa = channel->open_attempt;
2819 cmd = oa->cmd;
2820
2821 if (!fromwire_dualopend_psbt_changed(tmpctx, msg,
2822 &cid,
2823 &funding_serial,
2824 &psbt)) {
2825 channel_internal_error(channel,
2826 "Bad DUALOPEND_PSBT_CHANGED: %s",
2827 tal_hex(tmpctx, msg));
2828 return;
2829 }
2830
2831
2832 switch (oa->role) {
2833 case TX_INITIATOR:
2834 if (!cmd) {
2835 channel_err_broken(channel,
2836 tal_fmt(tmpctx, "Unexpected"
2837 " PSBT_CHANGED %s",
2838 tal_hex(tmpctx, msg)));
2839 return;
2840 }
2841 /* This might be the first time we learn the channel_id */
2842 channel->cid = cid;
2843 response = json_stream_success(cmd);
2844 json_add_string(response, "channel_id",
2845 type_to_string(tmpctx, struct channel_id,
2846 &channel->cid));
2847 json_add_psbt(response, "psbt", psbt);
2848 json_add_bool(response, "commitments_secured", false);
2849 json_add_u64(response, "funding_serial", funding_serial);
2850
2851 oa->cmd = NULL;
2852 was_pending(command_success(cmd, response));
2853 return;
2854 case TX_ACCEPTER:
2855 payload = tal(dualopend, struct openchannel2_psbt_payload);
2856 payload->dualopend = dualopend;
2857 tal_add_destructor2(dualopend,
2858 openchannel2_psbt_remove_dualopend,
2859 payload);
2860 payload->psbt = tal_steal(payload, psbt);
2861 payload->channel = channel;
2862 plugin_hook_call_openchannel2_changed(dualopend->ld, NULL, payload);

Callers 1

dual_opend_msgFunction · 0.85

Calls 12

tal_hexFunction · 0.85
channel_err_brokenFunction · 0.85
json_add_psbtFunction · 0.85
was_pendingFunction · 0.85
abortFunction · 0.85
channel_internal_errorFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
json_add_stringFunction · 0.50
type_to_stringClass · 0.50
json_add_boolFunction · 0.50
json_add_u64Function · 0.50

Tested by

no test coverage detected