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

Function json_dump_income

plugins/bkpr/bookkeeper.c:150–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static struct command_result *json_dump_income(struct command *cmd,
151 const char *buf,
152 const jsmntok_t *params)
153{
154 struct json_stream *res;
155 struct income_event **evs;
156 struct csv_fmt *csv_fmt;
157 const char *filename;
158 bool *consolidate_fees;
159 char *err;
160 u64 *start_time, *end_time;
161
162 if (!param(cmd, buf, params,
163 p_req("csv_format", param_csv_format, &csv_fmt),
164 p_opt("csv_file", param_string, &filename),
165 p_opt_def("consolidate_fees", param_bool,
166 &consolidate_fees, true),
167 p_opt_def("start_time", param_u64, &start_time, 0),
168 p_opt_def("end_time", param_u64, &end_time, SQLITE_MAX_UINT),
169 NULL))
170 return command_param_failed();
171
172 /* Ok, go find me some income events! */
173 db_begin_transaction(db);
174 evs = list_income_events(cmd, db, *start_time, *end_time,
175 *consolidate_fees);
176 db_commit_transaction(db);
177
178 if (!filename)
179 filename = csv_filename(cmd, csv_fmt);
180
181 err = csv_print_income_events(cmd, csv_fmt, filename, evs);
182 if (err)
183 return command_fail(cmd, PLUGIN_ERROR,
184 "Unable to create csv file: %s",
185 err);
186
187 res = jsonrpc_stream_success(cmd);
188 json_add_string(res, "csv_file", filename);
189 json_add_string(res, "csv_format", csv_fmt->fmt_name);
190 return command_finished(cmd, res);
191}
192
193static struct command_result *json_list_income(struct command *cmd,
194 const char *buf,

Callers

nothing calls this directly

Calls 10

list_income_eventsFunction · 0.85
csv_filenameFunction · 0.85
csv_print_income_eventsFunction · 0.85
paramFunction · 0.50
command_param_failedFunction · 0.50
db_commit_transactionFunction · 0.50
command_failFunction · 0.50
jsonrpc_stream_successFunction · 0.50
json_add_stringFunction · 0.50
command_finishedFunction · 0.50

Tested by

no test coverage detected