core-lightning/plugins/bkpr/account_entry.c
niftynei 3fcf60ab7c bkpr: track channel rebalances, display in listincome
Track rebalances, and report income events for them.

Previously `listincome` would report:
	- invoice event, debit, outgoing channel
	- invoice_fee event, debit, outgoing channel
	- invoice event, credit, inbound channel

Now reports:
	- rebalance_fee, debit, outgoing channel
	(same value as invoice_fee above)

Note: only applies on channel events; if a rebalance falls to chain
we'll use the older style of accounting.

Changelog-None
2022-08-09 11:57:18 +09:30

30 lines
533 B
C

#include "config.h"
#include <ccan/tal/str/str.h>
#include <plugins/bkpr/account_entry.h>
#include <stddef.h>
static const char *tags[] = {
"journal_entry",
"penalty_adj",
"invoice_fee",
"rebalance_fee",
};
const char *account_entry_tag_str(enum account_entry_tag tag)
{
return tags[tag];
}
bool account_entry_tag_find(char *str, enum account_entry_tag *tag)
{
for (size_t i = 0; i < NUM_ACCOUNT_ENTRY_TAGS; i++) {
if (streq(str, tags[i])) {
*tag = (enum account_entry_tag) i;
return true;
}
}
return false;
}