| 233 | AUTODATA(json_command, &listoffers_command); |
| 234 | |
| 235 | static struct command_result *json_disableoffer(struct command *cmd, |
| 236 | const char *buffer, |
| 237 | const jsmntok_t *obj UNNEEDED, |
| 238 | const jsmntok_t *params) |
| 239 | { |
| 240 | struct json_stream *response; |
| 241 | struct sha256 *offer_id; |
| 242 | struct wallet *wallet = cmd->ld->wallet; |
| 243 | const char *b12; |
| 244 | const struct json_escape *label; |
| 245 | enum offer_status status; |
| 246 | |
| 247 | if (!param(cmd, buffer, params, |
| 248 | p_req("offer_id", param_sha256, &offer_id), |
| 249 | NULL)) |
| 250 | return command_param_failed(); |
| 251 | |
| 252 | b12 = wallet_offer_find(tmpctx, wallet, offer_id, &label, &status); |
| 253 | if (!b12) |
| 254 | return command_fail(cmd, LIGHTNINGD, "Unknown offer"); |
| 255 | |
| 256 | if (!offer_status_active(status)) |
| 257 | return command_fail(cmd, OFFER_ALREADY_DISABLED, |
| 258 | "offer is not active"); |
| 259 | status = wallet_offer_disable(wallet, offer_id, status); |
| 260 | |
| 261 | response = json_stream_success(cmd); |
| 262 | json_populate_offer(response, offer_id, b12, |
| 263 | offer_str_nosig(tmpctx, |
| 264 | cmd->ld, b12), |
| 265 | label, status); |
| 266 | return command_success(cmd, response); |
| 267 | } |
| 268 | |
| 269 | static const struct json_command disableoffer_command = { |
| 270 | "disableoffer", |
nothing calls this directly
no test coverage detected