| 441 | }; |
| 442 | |
| 443 | static struct command_result *do_dump_income(struct command *cmd, |
| 444 | struct dump_income_info *info) |
| 445 | { |
| 446 | struct bkpr *bkpr = bkpr_of(cmd->plugin); |
| 447 | struct json_stream *res; |
| 448 | struct income_event **evs; |
| 449 | char *err; |
| 450 | |
| 451 | /* Ok, go find me some income events! */ |
| 452 | evs = list_income_events(cmd, bkpr, cmd, *info->start_time, *info->end_time, |
| 453 | *info->consolidate_fees); |
| 454 | |
| 455 | if (!info->filename) |
| 456 | info->filename = csv_filename(info, info->csv_fmt); |
| 457 | |
| 458 | err = csv_print_income_events(cmd, info->csv_fmt, info->filename, evs); |
| 459 | if (err) |
| 460 | return command_fail(cmd, PLUGIN_ERROR, |
| 461 | "Unable to create csv file: %s", |
| 462 | err); |
| 463 | |
| 464 | res = jsonrpc_stream_success(cmd); |
| 465 | json_add_string(res, "csv_file", info->filename); |
| 466 | json_add_string(res, "csv_format", info->csv_fmt->fmt_name); |
| 467 | return command_finished(cmd, res); |
| 468 | } |
| 469 | |
| 470 | static struct command_result *json_dump_income(struct command *cmd, |
| 471 | const char *buf, |
nothing calls this directly
no test coverage detected