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

Function json_channel_state_changed

plugins/funder.c:1136–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1134}
1135
1136static struct command_result *json_channel_state_changed(struct command *cmd,
1137 const char *buf,
1138 const jsmntok_t *params)
1139{
1140 struct channel_id cid;
1141 const char *err, *old_state, *new_state;
1142
1143 old_state = NULL;
1144 err = json_scan(tmpctx, buf, params,
1145 "{channel_state_changed:"
1146 "{channel_id:%"
1147 ",old_state?:%"
1148 ",new_state:%}}",
1149 JSON_SCAN(json_to_channel_id, &cid),
1150 JSON_SCAN_TAL(cmd, json_strdup, &old_state),
1151 JSON_SCAN_TAL(cmd, json_strdup, &new_state));
1152
1153 if (err)
1154 plugin_err(cmd->plugin,
1155 "`channel_state_changed` notification payload did"
1156 " not scan %s: %.*s",
1157 err, json_tok_full_len(params),
1158 json_tok_full(buf, params));
1159
1160 /* Moving out of "awaiting lockin",
1161 * means we clean up the datastore */
1162 /* FIXME: splicing state? */
1163 if (!old_state)
1164 return notification_handled(cmd);
1165
1166 if (!streq(old_state, "DUALOPEND_AWAITING_LOCKIN")
1167 && !streq(old_state, "CHANNELD_AWAITING_LOCKIN"))
1168 return notification_handled(cmd);
1169
1170 plugin_log(cmd->plugin, LOG_DBG,
1171 "Cleaning up datastore for channel_id %s",
1172 fmt_channel_id(tmpctx, &cid));
1173
1174 return delete_channel_from_datastore(cmd, &cid);
1175}
1176
1177static struct command_result *json_channel_open_failed(struct command *cmd,
1178 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