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

Function json_disableoffer

lightningd/offer.c:218–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216AUTODATA(json_command, &listoffers_command);
217
218static struct command_result *json_disableoffer(struct command *cmd,
219 const char *buffer,
220 const jsmntok_t *obj UNNEEDED,
221 const jsmntok_t *params)
222{
223 struct json_stream *response;
224 struct sha256 *offer_id;
225 struct wallet *wallet = cmd->ld->wallet;
226 const char *b12;
227 const char *description;
228 const struct json_escape *label;
229 enum offer_status status;
230 bool force_paths;
231
232 if (!param_check(cmd, buffer, params,
233 p_req("offer_id", param_sha256, &offer_id),
234 NULL))
235 return command_param_failed();
236
237 b12 = wallet_offer_find(tmpctx, wallet, offer_id,
238 &label, &status, &force_paths);
239 if (!b12)
240 return command_fail(cmd, LIGHTNINGD, "Unknown offer");
241
242 if (!offer_status_active(status))
243 return command_fail(cmd, OFFER_ALREADY_DISABLED,
244 "offer is not active");
245
246 if (command_check_only(cmd))
247 return command_check_done(cmd);
248
249 status = wallet_offer_disable(wallet, offer_id, status);
250
251 response = json_stream_success(cmd);
252 json_populate_offer(response, offer_id, b12, label, status, force_paths);
253 description = offer_description_from_b12(tmpctx, cmd->ld, b12);
254 if (description)
255 json_add_stringn(response, "description", description, tal_bytelen(description));
256 return command_success(cmd, response);
257}
258
259static const struct json_command disableoffer_command = {
260 "disableoffer",

Callers

nothing calls this directly

Calls 14

param_checkFunction · 0.85
offer_status_activeFunction · 0.85
wallet_offer_disableFunction · 0.85
json_populate_offerFunction · 0.85
json_add_stringnFunction · 0.85
tal_bytelenFunction · 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

Tested by

no test coverage detected