2016-01-21 21:11:47 +01:00
|
|
|
#ifndef LIGHTNING_DAEMON_LIGHTNING_H
|
|
|
|
#define LIGHTNING_DAEMON_LIGHTNING_H
|
|
|
|
#include "config.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "bitcoin/pubkey.h"
|
2016-01-21 21:11:49 +01:00
|
|
|
#include "watch.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <ccan/list/list.h>
|
2016-01-21 21:11:49 +01:00
|
|
|
#include <ccan/short_types/short_types.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <ccan/timer/timer.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <secp256k1.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <stdio.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
/* Various adjustable things. */
|
|
|
|
struct config {
|
2016-01-21 21:11:49 +01:00
|
|
|
/* Are we on testnet? */
|
|
|
|
bool testnet;
|
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
/* How long do we want them to lock up their funds? (blocks) */
|
|
|
|
u32 locktime_blocks;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
/* How long do we let them lock up our funds? (blocks) */
|
|
|
|
u32 locktime_max;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
|
|
|
/* How many confirms until we consider an anchor "settled". */
|
|
|
|
u32 anchor_confirms;
|
|
|
|
|
|
|
|
/* How long will we accept them waiting? */
|
|
|
|
u32 anchor_confirms_max;
|
|
|
|
|
2016-01-21 21:15:28 +01:00
|
|
|
/* How many blocks until we stop watching a close commit? */
|
|
|
|
u32 forever_confirms;
|
|
|
|
|
2016-08-18 06:53:46 +02:00
|
|
|
/* Maximum percent of fee rate we'll accept. */
|
|
|
|
u32 commitment_fee_max_percent;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
2016-08-18 06:53:46 +02:00
|
|
|
/* Minimum percent of fee rate we'll accept. */
|
|
|
|
u32 commitment_fee_min_percent;
|
2016-01-21 21:15:27 +01:00
|
|
|
|
2016-08-18 06:53:46 +02:00
|
|
|
/* Percent of fee rate we'll use. */
|
|
|
|
u32 commitment_fee_percent;
|
|
|
|
|
|
|
|
/* What fee we use if estimatefee fails (satoshis/kb) */
|
|
|
|
u64 default_fee_rate;
|
2016-01-21 21:15:27 +01:00
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
/* Minimum/maximum time for an expiring HTLC (blocks). */
|
|
|
|
u32 min_htlc_expiry, max_htlc_expiry;
|
2016-06-30 01:38:11 +02:00
|
|
|
|
2016-07-01 03:49:28 +02:00
|
|
|
/* How many blocks before upstream HTLC expiry do we panic and dump? */
|
|
|
|
u32 deadline_blocks;
|
|
|
|
|
2016-06-30 01:38:11 +02:00
|
|
|
/* Fee rates. */
|
|
|
|
u32 fee_base;
|
|
|
|
s32 fee_per_satoshi;
|
2016-01-21 21:15:28 +01:00
|
|
|
|
2016-05-09 22:59:12 +02:00
|
|
|
/* How long between polling bitcoind. */
|
|
|
|
struct timerel poll_time;
|
2016-05-09 23:00:11 +02:00
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
/* How long between changing commit and sending COMMIT message. */
|
2016-05-09 23:00:11 +02:00
|
|
|
struct timerel commit_time;
|
2016-01-21 21:11:49 +01:00
|
|
|
};
|
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
/* Here's where the global variables hide! */
|
|
|
|
struct lightningd_state {
|
|
|
|
/* Where all our logging goes. */
|
|
|
|
struct log_record *log_record;
|
|
|
|
struct log *base_log;
|
2016-01-21 21:11:47 +01:00
|
|
|
FILE *logf;
|
2016-01-21 21:11:48 +01:00
|
|
|
|
|
|
|
/* Our config dir, and rpc file */
|
|
|
|
char *config_dir;
|
|
|
|
char *rpc_filename;
|
2016-01-21 21:11:48 +01:00
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
/* Configuration settings. */
|
|
|
|
struct config config;
|
|
|
|
|
2016-08-18 06:55:13 +02:00
|
|
|
/* The database where we keep our stuff. */
|
|
|
|
struct db *db;
|
|
|
|
|
2016-01-21 21:11:48 +01:00
|
|
|
/* Any pending timers. */
|
2016-01-21 21:11:48 +01:00
|
|
|
struct timers timers;
|
|
|
|
|
2016-04-24 12:07:13 +02:00
|
|
|
/* Cached block topology. */
|
|
|
|
struct topology *topology;
|
|
|
|
|
2016-01-21 21:11:48 +01:00
|
|
|
/* Our peers. */
|
|
|
|
struct list_head peers;
|
2016-01-21 21:11:48 +01:00
|
|
|
|
|
|
|
/* Crypto tables for global use. */
|
|
|
|
secp256k1_context *secpctx;
|
2016-01-21 21:11:48 +01:00
|
|
|
|
|
|
|
/* Our private key */
|
|
|
|
struct secret *secret;
|
|
|
|
|
|
|
|
/* This is us. */
|
|
|
|
struct pubkey id;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
/* Transactions/txos we are watching. */
|
|
|
|
struct txwatch_hash txwatches;
|
|
|
|
struct txowatch_hash txowatches;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
|
|
|
/* Outstanding bitcoind requests. */
|
|
|
|
struct list_head bitcoin_req;
|
|
|
|
bool bitcoin_req_running;
|
2016-04-12 05:37:03 +02:00
|
|
|
|
|
|
|
/* Wallet addresses we maintain. */
|
|
|
|
struct list_head wallet;
|
2016-06-28 23:19:20 +02:00
|
|
|
|
|
|
|
/* Payments for r values we know about. */
|
|
|
|
struct list_head payments;
|
2016-06-28 23:19:21 +02:00
|
|
|
|
|
|
|
/* All known nodes. */
|
|
|
|
struct node_map *nodes;
|
2016-06-30 01:38:10 +02:00
|
|
|
|
|
|
|
/* For testing: don't fail if we can't route. */
|
|
|
|
bool dev_never_routefail;
|
2016-08-18 06:55:14 +02:00
|
|
|
|
|
|
|
/* Re-exec hack for testing. */
|
|
|
|
char **reexec;
|
2016-01-21 21:11:47 +01:00
|
|
|
};
|
|
|
|
#endif /* LIGHTNING_DAEMON_LIGHTNING_H */
|