| 1134 | } |
| 1135 | |
| 1136 | static 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 | |
| 1177 | static struct command_result *json_channel_open_failed(struct command *cmd, |
| 1178 | const char *buf, |
nothing calls this directly
no test coverage detected