Files
palladum-lightning/plugins/bkpr/channelsapy.h
Rusty Russell b70f4f6184 bkpr: convert all the local db sql queries into calls to sql plugin.
With some help (and hinderance!) from ChatGPT: the field names
differ slightly from our internal db.

The particilar wrinkle is that we have to restrict all queries to
limit them to entries we've seen already.  Our code expects this (we
used to only enter it into the db when we processed it), and it would
otherwise be confusing if a sql query returned inconsistent results
because an event occurred while bookkeeper was processing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-19 13:37:50 +09:30

46 lines
1.2 KiB
C

#ifndef LIGHTNING_PLUGINS_BKPR_CHANNELSAPY_H
#define LIGHTNING_PLUGINS_BKPR_CHANNELSAPY_H
#include "config.h"
#include <ccan/tal/tal.h>
struct channel_apy {
const char *acct_name;
struct amount_msat routed_in;
struct amount_msat routed_out;
struct amount_msat fees_in;
struct amount_msat fees_out;
struct amount_msat push_in;
struct amount_msat push_out;
struct amount_msat lease_in;
struct amount_msat lease_out;
struct amount_msat our_start_bal;
struct amount_msat total_start_bal;
/* Blockheight the channel opened */
u32 start_blockheight;
/* If channel_close, the channel_close event's blockheight,
* otherwise the current blockheight */
u32 end_blockheight;
};
struct channel_apy *new_channel_apy(const tal_t *ctx);
WARN_UNUSED_RESULT bool channel_apy_sum(struct channel_apy *sum_apy,
const struct channel_apy *entry);
struct channel_apy **compute_channel_apys(const tal_t *ctx,
const struct bkpr *bkpr,
struct command *cmd,
u64 start_time,
u64 end_time,
u32 current_blockheight);
void json_add_channel_apy(struct json_stream *res,
const struct channel_apy *apy);
#endif /* LIGHTNING_PLUGINS_BKPR_CHANNELSAPY_H */