2022-07-19 14:39:26 +09:30
|
|
|
#ifndef LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H
|
|
|
|
#define LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2022-07-19 17:04:37 +09:30
|
|
|
#include <bitcoin/tx.h>
|
2022-07-19 14:39:26 +09:30
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
|
|
|
|
struct amount_msat;
|
|
|
|
struct bitcoin_outpoint;
|
|
|
|
struct bitcoin_txid;
|
2022-07-19 17:04:37 +09:30
|
|
|
struct json_stream;
|
2022-07-19 14:39:26 +09:30
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-07-19 17:04:35 +09:30
|
|
|
/* Name of the account this belongs to */
|
|
|
|
char *acct_name;
|
|
|
|
|
2022-07-19 17:04:35 +09:30
|
|
|
/* Name of account this originated from */
|
|
|
|
char *origin_acct;
|
|
|
|
|
2022-07-19 14:39:26 +09:30
|
|
|
/* Tag describing the event */
|
|
|
|
const char *tag;
|
|
|
|
|
2022-07-19 17:04:38 +09:30
|
|
|
/* Is the node's wallet ignoring this? */
|
|
|
|
bool ignored;
|
|
|
|
|
2022-07-19 17:04:39 +09:30
|
|
|
/* Is this chain output stealable? If so
|
|
|
|
* we'll need to watch it for longer */
|
|
|
|
bool stealable;
|
|
|
|
|
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-07-31 16:55:58 -05:00
|
|
|
/* Is this a rebalance event? */
|
|
|
|
bool rebalance;
|
|
|
|
|
2022-07-19 14:39:26 +09:30
|
|
|
/* 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;
|
2022-07-19 17:04:40 +09:30
|
|
|
|
|
|
|
/* Desc of event (maybe useful for printing notes) */
|
|
|
|
const char *desc;
|
2022-07-19 14:39:26 +09:30
|
|
|
};
|
|
|
|
|
2022-07-19 17:04:37 +09:30
|
|
|
void json_add_chain_event(struct json_stream *out,
|
|
|
|
struct chain_event *ev);
|
|
|
|
|
2022-07-19 14:39:26 +09:30
|
|
|
#endif /* LIGHTNING_PLUGINS_BKPR_CHAIN_EVENT_H */
|