| 250 | } |
| 251 | |
| 252 | static struct command_result *json_deldatastore(struct command *cmd, |
| 253 | const char *buffer, |
| 254 | const jsmntok_t *obj UNNEEDED, |
| 255 | const jsmntok_t *params) |
| 256 | { |
| 257 | struct json_stream *response; |
| 258 | const char **key; |
| 259 | const u8 *data; |
| 260 | u64 *generation; |
| 261 | u64 actual_gen; |
| 262 | |
| 263 | if (!param_check(cmd, buffer, params, |
| 264 | p_req("key", param_list_or_string, &key), |
| 265 | p_opt("generation", param_u64, &generation), |
| 266 | NULL)) |
| 267 | return command_param_failed(); |
| 268 | |
| 269 | data = wallet_datastore_get(cmd, cmd->ld->wallet, key, &actual_gen); |
| 270 | if (!data) { |
| 271 | return command_fail(cmd, DATASTORE_DEL_DOES_NOT_EXIST, |
| 272 | "Key does not exist"); |
| 273 | } |
| 274 | if (generation && actual_gen != *generation) |
| 275 | return command_fail(cmd, DATASTORE_DEL_WRONG_GENERATION, |
| 276 | "generation is different"); |
| 277 | |
| 278 | if (command_check_only(cmd)) |
| 279 | return command_check_done(cmd); |
| 280 | |
| 281 | wallet_datastore_remove(cmd->ld->wallet, key); |
| 282 | |
| 283 | response = json_stream_success(cmd); |
| 284 | json_add_datastore(response, key, data, actual_gen); |
| 285 | return command_success(cmd, response); |
| 286 | } |
| 287 | |
| 288 | static struct command_result *json_datastoreusage(struct command *cmd, |
| 289 | const char *buffer, |
nothing calls this directly
no test coverage detected