| 1171 | } |
| 1172 | |
| 1173 | static 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 | |
| 1214 | static struct command_result *json_channel_open_failed(struct command *cmd, |
| 1215 | const char *buf, |
nothing calls this directly
no test coverage detected