| 216 | AUTODATA(json_command, &listoffers_command); |
| 217 | |
| 218 | static 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 | |
| 259 | static const struct json_command disableoffer_command = { |
| 260 | "disableoffer", |
nothing calls this directly
no test coverage detected