forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightningd.h
167 lines (125 loc) · 4.14 KB
/
lightningd.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef LIGHTNING_LIGHTNINGD_LIGHTNINGD_H
#define LIGHTNING_LIGHTNINGD_LIGHTNINGD_H
#include "config.h"
#include <bitcoin/chainparams.h>
#include <bitcoin/privkey.h>
#include <ccan/container_of/container_of.h>
#include <ccan/time/time.h>
#include <ccan/timer/timer.h>
#include <lightningd/htlc_end.h>
#include <stdio.h>
#include <wallet/wallet.h>
/* BOLT #1:
*
* The default TCP port is 9735. This corresponds to hexadecimal
* `0x2607`, the Unicode code point for LIGHTNING.
*/
#define DEFAULT_PORT 9735
/* Various adjustable things. */
struct config {
/* How long do we want them to lock up their funds? (blocks) */
u32 locktime_blocks;
/* How long do we let them lock up our funds? (blocks) */
u32 locktime_max;
/* How many blocks before we expect to see anchor?. */
u32 anchor_onchain_wait;
/* How many confirms until we consider an anchor "settled". */
u32 anchor_confirms;
/* How long will we accept them waiting? */
u32 anchor_confirms_max;
/* How many blocks until we stop watching a close commit? */
u32 forever_confirms;
/* Maximum percent of fee rate we'll accept. */
u32 commitment_fee_max_percent;
/* Minimum percent of fee rate we'll accept. */
u32 commitment_fee_min_percent;
/* Percent of fee rate we'll use. */
u32 commitment_fee_percent;
/* Minimum CLTV to subtract from incoming HTLCs to outgoing */
u32 cltv_expiry_delta;
/* Minimum CLTV if we're the final hop.*/
u32 cltv_final;
/* Maximum time for an expiring HTLC (blocks). */
u32 max_htlc_expiry;
/* Fee rates. */
u32 fee_base;
s32 fee_per_satoshi;
/* How long between polling bitcoind. */
struct timerel poll_time;
/* How long between changing commit and sending COMMIT message. */
struct timerel commit_time;
/* Disable automatic reconnects */
bool no_reconnect;
};
struct lightningd {
/* The directory to find all the subdaemons. */
const char *daemon_dir;
/* Our config dir, and rpc file */
char *config_dir;
char *rpc_filename;
/* Configuration settings. */
struct config config;
/* Log for general stuff. */
struct log_book *log_book;
struct log *log;
/* This is us. */
struct pubkey id;
/* My name is... my favorite color is... */
char *alias; /* At least 32 bytes (zero-filled) */
u8 *rgb; /* tal_len() == 3. */
/* Any pending timers. */
struct timers timers;
/* Port we're listening on */
u16 portnum;
/* Addresses to announce to the network (tal_count()) */
struct wireaddr *wireaddrs;
/* Bearer of all my secrets. */
int hsm_fd;
/* Daemon looking after peers during init / before channel. */
struct subd *gossip;
/* All peers we're tracking. */
struct list_head peers;
/* FIXME: This should stay in HSM */
struct secret peer_seed;
/* Outstanding connect commands. */
struct list_head connects;
/* Our chain topology. */
struct chain_topology *topology;
/* HTLCs in flight. */
struct htlc_in_map htlcs_in;
struct htlc_out_map htlcs_out;
u32 broadcast_interval;
struct wallet *wallet;
/* Maintained by invoices.c */
struct invoices *invoices;
/* Any outstanding "pay" commands. */
struct list_head pay_commands;
#if DEVELOPER
/* If we want to debug a subdaemon. */
const char *dev_debug_subdaemon;
/* If we want to set a specific non-random HSM seed. */
const u8 *dev_hsm_seed;
/* If we have a --dev-disconnect file */
int dev_disconnect_fd;
/* If we have --dev-fail-on-subdaemon-fail */
bool dev_subdaemon_fail;
#endif /* DEVELOPER */
};
/**
* derive_peer_seed - Generate a unique secret for this peer's channel
*
* @ld: the lightning daemon to get global secret from
* @peer_seed: where to store the generated secret
* @peer_id: the id node_id of the remote peer
* @chan_id: channel ID
*
* This method generates a unique secret from the given parameters. It
* is important that this secret be unique for each channel, but it
* must be reproducible for the same channel in case of
* reconnection. We use the DB channel ID to guarantee unique secrets
* per channel.
*/
void derive_peer_seed(struct lightningd *ld, struct privkey *peer_seed,
const struct pubkey *peer_id, const u64 channel_id);
struct chainparams *get_chainparams(const struct lightningd *ld);
#endif /* LIGHTNING_LIGHTNINGD_LIGHTNINGD_H */