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

Function json_deldatastore

lightningd/datastore.c:252–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252static 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
288static struct command_result *json_datastoreusage(struct command *cmd,
289 const char *buffer,

Callers

nothing calls this directly

Calls 10

param_checkFunction · 0.85
wallet_datastore_getFunction · 0.85
wallet_datastore_removeFunction · 0.85
json_add_datastoreFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected