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

Function list_awaiting_channels

plugins/spender/openchannel.c:1083–1123  ·  view source on GitHub ↗

If there are any channels with unsigned PSBTs in AWAITING_LOCKIN, * sign them now (assume we crashed) */

Source from the content-addressed store, hash-verified

1081/* If there are any channels with unsigned PSBTs in AWAITING_LOCKIN,
1082 * sign them now (assume we crashed) */
1083static void list_awaiting_channels(struct command *init_cmd)
1084{
1085 const char *buf;
1086 size_t i;
1087 const jsmntok_t *resp, *t, *channels;
1088
1089 resp = jsonrpc_request_sync(tmpctx, init_cmd,
1090 "listpeerchannels",
1091 NULL, &buf);
1092 channels = json_get_member(buf, resp, "channels");
1093 json_for_each_arr(i, t, channels) {
1094 struct out_req *req;
1095 const char *state;
1096 struct channel_id cid;
1097 struct command *aux_cmd;
1098 struct wally_psbt *psbt;
1099 bool withheld;
1100
1101 if (json_scan(tmpctx, buf, t, "{state:%,channel_id:%,funding:{withheld:%,psbt:%}}",
1102 JSON_SCAN_TAL(tmpctx, json_strdup, &state),
1103 JSON_SCAN(json_tok_channel_id, &cid),
1104 JSON_SCAN(json_to_bool, &withheld),
1105 JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt)) != NULL)
1106 continue;
1107
1108 if (!streq(state, "CHANNELD_AWAITING_LOCKIN")
1109 && !streq(state, "DUALOPEND_AWAITING_LOCKIN"))
1110 continue;
1111
1112 if (withheld)
1113 continue;
1114
1115 /* Don't do this sync, as it can reasonably fail! */
1116 aux_cmd = aux_command(init_cmd);
1117 req = jsonrpc_request_start(aux_cmd, "signpsbt",
1118 signpsbt_done, psbt_error,
1119 tal_dup(aux_cmd, struct channel_id, &cid));
1120 json_add_psbt(req->js, "psbt", psbt);
1121 send_outreq(req);
1122 }
1123}
1124
1125void openchannel_init(struct command *init_cmd, const char *b, const jsmntok_t *t)
1126{

Callers 1

openchannel_initFunction · 0.85

Calls 6

json_get_memberFunction · 0.85
json_add_psbtFunction · 0.85
jsonrpc_request_syncFunction · 0.50
json_scanFunction · 0.50
aux_commandFunction · 0.50
send_outreqFunction · 0.50

Tested by

no test coverage detected