2017-01-10 06:07:51 +01:00
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_LIGHTNINGD_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_LIGHTNINGD_H
|
|
|
|
#include "config.h"
|
2017-02-24 06:52:56 +01:00
|
|
|
#include <bitcoin/privkey.h>
|
2017-01-10 06:08:33 +01:00
|
|
|
#include <ccan/container_of/container_of.h>
|
2017-01-10 06:07:51 +01:00
|
|
|
#include <daemon/lightningd.h>
|
2017-04-01 13:01:13 +02:00
|
|
|
#include <lightningd/htlc_end.h>
|
2017-05-23 22:07:20 +02:00
|
|
|
#include <wallet/wallet.h>
|
2017-01-10 06:07:51 +01:00
|
|
|
|
|
|
|
/* BOLT #1:
|
|
|
|
*
|
|
|
|
* The default TCP port is 9735. This corresponds to hexadecimal
|
2017-06-06 01:48:10 +02:00
|
|
|
* `0x2607`, the Unicode code point for LIGHTNING.
|
2017-01-10 06:07:51 +01:00
|
|
|
*/
|
|
|
|
#define DEFAULT_PORT 0x2607
|
|
|
|
|
|
|
|
/* FIXME: This is two structures, during the migration from old setup to new */
|
|
|
|
struct lightningd {
|
|
|
|
/* Must be first, since things assume we can tal() off it */
|
|
|
|
struct lightningd_state dstate;
|
|
|
|
|
|
|
|
/* The directory to find all the subdaemons. */
|
|
|
|
const char *daemon_dir;
|
|
|
|
|
|
|
|
/* Log for general stuff. */
|
|
|
|
struct log *log;
|
2017-01-10 06:08:33 +01:00
|
|
|
|
|
|
|
/* Bearer of all my secrets. */
|
2017-03-10 11:49:43 +01:00
|
|
|
struct subd *hsm;
|
2017-01-10 06:08:33 +01:00
|
|
|
|
2017-01-10 06:08:33 +01:00
|
|
|
/* Daemon looking after peers during init / before channel. */
|
2017-03-10 11:50:43 +01:00
|
|
|
struct subd *gossip;
|
2017-01-10 06:08:33 +01:00
|
|
|
|
2017-01-10 06:08:33 +01:00
|
|
|
/* All peers we're tracking. */
|
|
|
|
struct list_head peers;
|
2017-02-24 06:52:56 +01:00
|
|
|
/* FIXME: This should stay in HSM */
|
2017-05-06 04:19:44 +02:00
|
|
|
struct secret peer_seed;
|
2017-02-24 06:52:56 +01:00
|
|
|
/* Used to give a unique seed to every peer. */
|
|
|
|
u64 peer_counter;
|
2017-02-21 05:45:29 +01:00
|
|
|
|
2017-02-21 05:49:02 +01:00
|
|
|
/* Public base for bip32 keys, and max we've ever used. */
|
2017-02-21 05:45:29 +01:00
|
|
|
struct ext_key *bip32_base;
|
2017-02-21 05:49:02 +01:00
|
|
|
|
2017-03-07 01:56:38 +01:00
|
|
|
/* Our bitcoind context. */
|
|
|
|
struct bitcoind *bitcoind;
|
|
|
|
|
|
|
|
/* Our chain topology. */
|
|
|
|
struct chain_topology *topology;
|
|
|
|
|
2017-02-24 06:52:56 +01:00
|
|
|
/* If we want to debug a subdaemon. */
|
|
|
|
const char *dev_debug_subdaemon;
|
|
|
|
|
2017-05-24 12:10:16 +02:00
|
|
|
/* If we have a --dev-disconnect file */
|
|
|
|
int dev_disconnect_fd;
|
|
|
|
|
2017-04-01 13:01:13 +02:00
|
|
|
/* HTLCs in flight. */
|
2017-06-20 07:53:03 +02:00
|
|
|
struct htlc_in_map htlcs_in;
|
|
|
|
struct htlc_out_map htlcs_out;
|
2017-04-24 14:31:26 +02:00
|
|
|
|
|
|
|
u32 broadcast_interval;
|
2017-05-23 22:07:20 +02:00
|
|
|
|
|
|
|
struct wallet *wallet;
|
2017-01-10 06:07:51 +01:00
|
|
|
};
|
2017-01-10 06:08:33 +01:00
|
|
|
|
2017-02-24 06:52:56 +01:00
|
|
|
void derive_peer_seed(struct lightningd *ld, struct privkey *peer_seed,
|
|
|
|
const struct pubkey *peer_id);
|
2017-03-09 14:06:17 +01:00
|
|
|
struct peer *find_peer_by_unique_id(struct lightningd *ld, u64 unique_id);
|
2017-01-10 06:08:33 +01:00
|
|
|
/* FIXME */
|
|
|
|
static inline struct lightningd *
|
|
|
|
ld_from_dstate(const struct lightningd_state *dstate)
|
|
|
|
{
|
|
|
|
return container_of(dstate, struct lightningd, dstate);
|
|
|
|
}
|
2017-01-10 06:07:51 +01:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_LIGHTNINGD_H */
|