core-lightning/plugins/bkpr/chain_event.h
niftynei a3d82d5a01 bkpr: exclude non-wallet events in the balance snapshot
Anchor outputs are ignored by the clightning wallet, but we keep track
of them in the bookkeeper. This causes problems when we do the balance
checks on restart w/ the balance_snapshot -- it results in us printing
out a journal_entry to 'get rid of' the anchors that the clightning node
doesnt know about.

Instead, we mark some outputs as 'ignored' and exclude these from our
account balance sums when we're comparing to the clightning snapshot.
2022-07-28 12:08:18 +09:30

64 lines
1.4 KiB
C

#ifndef LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H
#define LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H
#include "config.h"
#include <bitcoin/tx.h>
#include <ccan/short_types/short_types.h>
struct amount_msat;
struct bitcoin_outpoint;
struct bitcoin_txid;
struct json_stream;
struct chain_event {
/* Id of this chain event in the database */
u64 db_id;
/* db_id of account this event belongs to */
u64 acct_db_id;
/* Name of the account this belongs to */
char *acct_name;
/* Name of account this originated from */
char *origin_acct;
/* Tag describing the event */
const char *tag;
/* Is the node's wallet ignoring this? */
bool ignored;
/* Amount we received in this event */
struct amount_msat credit;
/* Amount we paid in this event */
struct amount_msat debit;
/* Total 'amount' of output on this chain event */
struct amount_msat output_value;
/* What token are the credit/debits? */
const char *currency;
/* What time did the event happen */
u64 timestamp;
/* What block did the event happen */
u32 blockheight;
/* What txo did this event concern */
struct bitcoin_outpoint outpoint;
/* What tx was the outpoint spent in (if spent) */
struct bitcoin_txid *spending_txid;
/* Sometimes chain events resolve payments */
struct sha256 *payment_id;
};
void json_add_chain_event(struct json_stream *out,
struct chain_event *ev);
#endif /* LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H */