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

Function json_channel_state_changed

plugins/funder.c:1173–1212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171}
1172
1173static struct command_result *json_channel_state_changed(struct command *cmd,
1174 const char *buf,
1175 const jsmntok_t *params)
1176{
1177 struct channel_id cid;
1178 const char *err, *old_state, *new_state;
1179
1180 old_state = NULL;
1181 err = json_scan(tmpctx, buf, params,
1182 "{channel_state_changed:"
1183 "{channel_id:%"
1184 ",old_state?:%"
1185 ",new_state:%}}",
1186 JSON_SCAN(json_to_channel_id, &cid),
1187 JSON_SCAN_TAL(cmd, json_strdup, &old_state),
1188 JSON_SCAN_TAL(cmd, json_strdup, &new_state));
1189
1190 if (err)
1191 plugin_err(cmd->plugin,
1192 "`channel_state_changed` notification payload did"
1193 " not scan %s: %.*s",
1194 err, json_tok_full_len(params),
1195 json_tok_full(buf, params));
1196
1197 /* Moving out of "awaiting lockin",
1198 * means we clean up the datastore */
1199 /* FIXME: splicing state? */
1200 if (!old_state)
1201 return notification_handled(cmd);
1202
1203 if (!streq(old_state, "DUALOPEND_AWAITING_LOCKIN")
1204 && !streq(old_state, "CHANNELD_AWAITING_LOCKIN"))
1205 return notification_handled(cmd);
1206
1207 plugin_log(cmd->plugin, LOG_DBG,
1208 "Cleaning up datastore for channel_id %s",
1209 fmt_channel_id(tmpctx, &cid));
1210
1211 return delete_channel_from_datastore(cmd, &cid);
1212}
1213
1214static struct command_result *json_channel_open_failed(struct command *cmd,
1215 const char *buf,

Callers

nothing calls this directly

Calls 8

plugin_errFunction · 0.70
notification_handledFunction · 0.70
plugin_logFunction · 0.70
json_scanFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected