mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-01 13:24:31 +01:00
Prints out the `listincome` events as a CSV formatted file Current csv_format options: - koinly - cointracker - harmony (https://github.com/harmony-csv/harmony) - quickbooks* *Quickbooks expects values in 'USD', whereas we print values out in <currency> (will be noted in the Description field). This won't work how you'd expect -> you might need to do some conversion etc before uploading it. All amounts emitted as 'btc' w/ *11* decimals.
57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#ifndef LIGHTNING_PLUGINS_BKPR_INCOMESTMT_H
|
|
#define LIGHTNING_PLUGINS_BKPR_INCOMESTMT_H
|
|
|
|
#include "config.h"
|
|
#include <ccan/tal/tal.h>
|
|
#include <stdio.h>
|
|
|
|
struct income_event {
|
|
char *acct_name;
|
|
char *tag;
|
|
struct amount_msat credit;
|
|
struct amount_msat debit;
|
|
char *currency;
|
|
u64 timestamp;
|
|
|
|
struct bitcoin_outpoint *outpoint;
|
|
struct bitcoin_txid *txid;
|
|
struct sha256 *payment_id;
|
|
};
|
|
|
|
/* Each csv format has a header and a 'row print' function */
|
|
struct csv_fmt {
|
|
char *fmt_name;
|
|
void (*emit_header)(FILE *);
|
|
void (*emit_entry)(const tal_t *, FILE *, struct income_event *);
|
|
};
|
|
|
|
/* List all the events that are income related (gain/loss) */
|
|
struct income_event **list_income_events_all(const tal_t *ctx, struct db *db,
|
|
bool consolidate_fees);
|
|
|
|
/* List all the events that are income related (gain/loss),
|
|
* by a start and end date */
|
|
struct income_event **list_income_events(const tal_t *ctx,
|
|
struct db *db,
|
|
u64 start_time,
|
|
u64 end_time,
|
|
bool consolidate_fees);
|
|
|
|
/* Given an event and a json_stream, add a new event object to the stream */
|
|
void json_add_income_event(struct json_stream *str, struct income_event *ev);
|
|
|
|
char *csv_print_income_events(const tal_t *ctx,
|
|
const struct csv_fmt *csvfmt,
|
|
const char *filename,
|
|
struct income_event **evs);
|
|
|
|
const struct csv_fmt *csv_match_token(const char *buffer, const jsmntok_t *tok);
|
|
|
|
/* Returns concatenated string of all available fmts */
|
|
const char *csv_list_fmts(const tal_t *ctx);
|
|
|
|
/* Generic income statement filename generator */
|
|
const char *csv_filename(const tal_t *ctx, const struct csv_fmt *fmt);
|
|
|
|
#endif /* LIGHTNING_PLUGINS_BKPR_INCOMESTMT_H */
|