1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef LIGHTNING_PLUGINS_BKPR_ACCOUNT_H
#define LIGHTNING_PLUGINS_BKPR_ACCOUNT_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <common/coin_mvt.h>
struct node_id;
struct chain_event;
struct command;
struct account {
/* Unique name of account, typically channel id */
const char *name;
/* Peer we have this account with (NULL if not a channel) */
struct node_id *peer_id;
/* Is this our internal wallet account? */
bool is_wallet;
/* Is this an account we initiated open for? */
bool we_opened;
/* Was any portion of this account's funds leased? */
bool leased;
/* Block account was totally resolved at */
u64 onchain_resolved_block;
/* db_id of chain event that opened this account */
u64 *open_event_db_id;
/* db_id of chain event that closed this account */
u64 *closed_event_db_id;
/* Number of outputs to expect on close */
u32 closed_count;
};
struct bkpr;
/* Initialize the accounts subsystem */
struct accounts *init_accounts(const tal_t *ctx, struct command *init_cmd);
/* Get all accounts */
struct account **list_accounts(const tal_t *ctx, const struct bkpr *bkpr);
/* Given an account name, find that account record */
struct account *find_account(const struct bkpr *bkpr,
const char *name);
/* Create it if it's not found */
struct account *find_or_create_account(struct command *cmd,
struct bkpr *bkpr,
const char *name);
/* Some events update account information */
void maybe_update_account(struct command *cmd,
struct account *acct,
struct chain_event *e,
const enum mvt_tag *tags,
u32 closed_count,
struct node_id *peer_id);
/* Update the account with the highest blockheight that has a
* resolving tx in it.
*
* The point of this is to allow us to prune data, eventually */
void account_update_closeheight(struct command *cmd,
struct account *acct,
u64 close_height);
#endif /* LIGHTNING_PLUGINS_BKPR_ACCOUNT_H */