2016-01-21 21:11:49 +01:00
|
|
|
#include "bitcoind.h"
|
2016-04-24 12:07:13 +02:00
|
|
|
#include "chaintopology.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "configdir.h"
|
2016-01-21 21:15:28 +01:00
|
|
|
#include "controlled_time.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "jsonrpc.h"
|
2016-01-21 21:11:47 +01:00
|
|
|
#include "lightningd.h"
|
|
|
|
#include "log.h"
|
2016-05-09 22:59:12 +02:00
|
|
|
#include "opt_time.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "peer.h"
|
2016-06-28 23:19:21 +02:00
|
|
|
#include "routing.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "secrets.h"
|
2016-01-21 21:11:48 +01:00
|
|
|
#include "timeout.h"
|
|
|
|
#include <ccan/container_of/container_of.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <ccan/err/err.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <ccan/io/io.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <ccan/opt/opt.h>
|
|
|
|
#include <ccan/tal/str/str.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <ccan/tal/tal.h>
|
2016-05-09 22:59:12 +02:00
|
|
|
#include <ccan/time/time.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <ccan/timer/timer.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <errno.h>
|
2016-01-21 21:11:49 +01:00
|
|
|
#include <inttypes.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <string.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <sys/socket.h>
|
2016-01-21 21:11:48 +01:00
|
|
|
#include <sys/stat.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
#include <version.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
static char *opt_set_u64(const char *arg, u64 *u)
|
|
|
|
{
|
|
|
|
char *endp;
|
|
|
|
unsigned long long l;
|
|
|
|
|
|
|
|
/* This is how the manpage says to do it. Yech. */
|
|
|
|
errno = 0;
|
|
|
|
l = strtoull(arg, &endp, 0);
|
|
|
|
if (*endp || !arg[0])
|
|
|
|
return tal_fmt(NULL, "'%s' is not a number", arg);
|
|
|
|
*u = l;
|
|
|
|
if (errno || *u != l)
|
|
|
|
return tal_fmt(NULL, "'%s' is out of range", arg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *opt_set_u32(const char *arg, u32 *u)
|
|
|
|
{
|
|
|
|
char *endp;
|
|
|
|
unsigned long l;
|
|
|
|
|
|
|
|
/* This is how the manpage says to do it. Yech. */
|
|
|
|
errno = 0;
|
|
|
|
l = strtoul(arg, &endp, 0);
|
|
|
|
if (*endp || !arg[0])
|
|
|
|
return tal_fmt(NULL, "'%s' is not a number", arg);
|
|
|
|
*u = l;
|
|
|
|
if (errno || *u != l)
|
|
|
|
return tal_fmt(NULL, "'%s' is out of range", arg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-30 01:38:11 +02:00
|
|
|
static char *opt_set_s32(const char *arg, s32 *u)
|
|
|
|
{
|
|
|
|
char *endp;
|
|
|
|
long l;
|
|
|
|
|
|
|
|
/* This is how the manpage says to do it. Yech. */
|
|
|
|
errno = 0;
|
|
|
|
l = strtol(arg, &endp, 0);
|
|
|
|
if (*endp || !arg[0])
|
|
|
|
return tal_fmt(NULL, "'%s' is not a number", arg);
|
|
|
|
*u = l;
|
|
|
|
if (errno || *u != l)
|
|
|
|
return tal_fmt(NULL, "'%s' is out of range", arg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
static void opt_show_u64(char buf[OPT_SHOW_LEN], const u64 *u)
|
|
|
|
{
|
|
|
|
snprintf(buf, OPT_SHOW_LEN, "%"PRIu64, *u);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void opt_show_u32(char buf[OPT_SHOW_LEN], const u32 *u)
|
|
|
|
{
|
|
|
|
snprintf(buf, OPT_SHOW_LEN, "%"PRIu32, *u);
|
|
|
|
}
|
|
|
|
|
2016-06-30 01:38:11 +02:00
|
|
|
static void opt_show_s32(char buf[OPT_SHOW_LEN], const s32 *u)
|
|
|
|
{
|
|
|
|
snprintf(buf, OPT_SHOW_LEN, "%"PRIi32, *u);
|
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
static void config_register_opts(struct lightningd_state *dstate)
|
2016-01-21 21:11:49 +01:00
|
|
|
{
|
2016-06-28 23:19:21 +02:00
|
|
|
opt_register_arg("--locktime-blocks", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.locktime_blocks,
|
|
|
|
"Blocks before peer can unilaterally spend funds");
|
|
|
|
opt_register_arg("--max-locktime-blocks", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.locktime_max,
|
2016-01-21 21:11:49 +01:00
|
|
|
"Maximum seconds peer can lock up our funds");
|
|
|
|
opt_register_arg("--anchor-confirms", opt_set_u32, opt_show_u32,
|
2016-01-21 21:11:49 +01:00
|
|
|
&dstate->config.anchor_confirms,
|
2016-01-21 21:11:49 +01:00
|
|
|
"Confirmations required for anchor transaction");
|
|
|
|
opt_register_arg("--max-anchor-confirms", opt_set_u32, opt_show_u32,
|
2016-01-21 21:11:49 +01:00
|
|
|
&dstate->config.anchor_confirms_max,
|
2016-01-21 21:11:49 +01:00
|
|
|
"Maximum confirmations other side can wait for anchor transaction");
|
2016-01-21 21:15:28 +01:00
|
|
|
opt_register_arg("--forever-confirms", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.forever_confirms,
|
|
|
|
"Confirmations after which we consider a reorg impossible");
|
2016-03-24 02:42:43 +01:00
|
|
|
opt_register_arg("--commit-fee-rate", opt_set_u64, opt_show_u64,
|
|
|
|
&dstate->config.commitment_fee_rate,
|
|
|
|
"Satoshis to offer for commitment transaction fee (per kb)");
|
|
|
|
opt_register_arg("--min-commit-fee-rate", opt_set_u64, opt_show_u64,
|
|
|
|
&dstate->config.commitment_fee_rate_min,
|
|
|
|
"Minimum satoshis to accept for commitment transaction fee (per kb)");
|
|
|
|
opt_register_arg("--closing-fee-rate", opt_set_u64, opt_show_u64,
|
|
|
|
&dstate->config.closing_fee_rate,
|
|
|
|
"Satoshis to use for mutual close transaction fee (per kb)");
|
2016-06-28 23:19:21 +02:00
|
|
|
opt_register_arg("--min-htlc-expiry", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.min_htlc_expiry,
|
|
|
|
"Minimum number of blocks to accept an HTLC before expiry");
|
|
|
|
opt_register_arg("--max-htlc-expiry", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.max_htlc_expiry,
|
|
|
|
"Maximum number of blocks to accept an HTLC before expiry");
|
2016-07-01 03:49:28 +02:00
|
|
|
opt_register_arg("--deadline-blocks", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.deadline_blocks,
|
|
|
|
"Number of blocks before HTLC timeout before we drop connection");
|
2016-05-09 22:59:12 +02:00
|
|
|
opt_register_arg("--bitcoind-poll", opt_set_time, opt_show_time,
|
|
|
|
&dstate->config.poll_time,
|
|
|
|
"Time between polling for new transactions");
|
2016-05-09 23:00:11 +02:00
|
|
|
opt_register_arg("--commit-time", opt_set_time, opt_show_time,
|
|
|
|
&dstate->config.commit_time,
|
|
|
|
"Time after changes before sending out COMMIT");
|
2016-06-30 01:38:11 +02:00
|
|
|
opt_register_arg("--fee-base", opt_set_u32, opt_show_u32,
|
|
|
|
&dstate->config.fee_base,
|
|
|
|
"Millisatoshi minimum to charge for HTLC");
|
|
|
|
opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32,
|
|
|
|
&dstate->config.fee_per_satoshi,
|
|
|
|
"Microsatoshi fee for every satoshi in HTLC");
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void default_config(struct config *config)
|
|
|
|
{
|
2016-01-21 21:11:49 +01:00
|
|
|
/* aka. "Dude, where's my coins?" */
|
|
|
|
config->testnet = true;
|
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
/* ~one day to catch cheating attempts. */
|
|
|
|
config->locktime_blocks = 6 * 24;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
|
|
|
/* They can have up to 3 days. */
|
2016-06-28 23:19:21 +02:00
|
|
|
config->locktime_max = 3 * 6 * 24;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
|
|
|
/* We're fairly trusting, under normal circumstances. */
|
|
|
|
config->anchor_confirms = 3;
|
|
|
|
|
|
|
|
/* More than 10 confirms seems overkill. */
|
|
|
|
config->anchor_confirms_max = 10;
|
|
|
|
|
2016-01-21 21:15:28 +01:00
|
|
|
/* At some point, you've got to let it go... */
|
2016-05-04 08:42:50 +02:00
|
|
|
/* BOLT #onchain:
|
|
|
|
*
|
|
|
|
* Outputs... are considered *irrevocably resolved* once they
|
|
|
|
* are included in a block at least 100 deep on the most-work
|
|
|
|
* blockchain. 100 blocks is far greater than the longest
|
|
|
|
* known bitcoin fork, and the same value used to wait for
|
|
|
|
* confirmations of miner's rewards[1].
|
|
|
|
*/
|
2016-01-21 21:15:28 +01:00
|
|
|
config->forever_confirms = 100;
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
/* FIXME: These should float with bitcoind's recommendations! */
|
|
|
|
|
2016-03-24 02:42:43 +01:00
|
|
|
/* Pay hefty fee (double historic high of ~100k). */
|
|
|
|
config->commitment_fee_rate = 200000;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
2016-03-24 02:42:43 +01:00
|
|
|
/* Don't accept less than double the average 2-block fee. */
|
|
|
|
config->commitment_fee_rate_min = 50000;
|
2016-01-21 21:15:27 +01:00
|
|
|
|
2016-01-21 21:15:27 +01:00
|
|
|
/* Use this for mutual close. */
|
2016-03-24 02:42:43 +01:00
|
|
|
config->closing_fee_rate = 20000;
|
2016-01-21 21:15:28 +01:00
|
|
|
|
|
|
|
/* Don't bother me unless I have 6 hours to collect. */
|
2016-06-28 23:19:21 +02:00
|
|
|
config->min_htlc_expiry = 6 * 6;
|
2016-01-21 21:15:28 +01:00
|
|
|
/* Don't lock up channel for more than 5 days. */
|
2016-06-28 23:19:21 +02:00
|
|
|
config->max_htlc_expiry = 5 * 6 * 24;
|
2016-01-21 21:15:28 +01:00
|
|
|
|
2016-07-01 03:49:28 +02:00
|
|
|
/* If we're closing on HTLC expiry, and you're unresponsive, we abort. */
|
|
|
|
config->deadline_blocks = 10;
|
|
|
|
|
|
|
|
/* How often to bother bitcoind. */
|
2016-05-09 22:59:12 +02:00
|
|
|
config->poll_time = time_from_sec(30);
|
2016-05-09 23:00:11 +02:00
|
|
|
|
|
|
|
/* Send commit 10msec after receiving; almost immediately. */
|
|
|
|
config->commit_time = time_from_msec(10);
|
2016-06-30 01:38:11 +02:00
|
|
|
|
|
|
|
/* Discourage dust payments */
|
|
|
|
config->fee_base = 546000;
|
|
|
|
/* Take 0.001% */
|
|
|
|
config->fee_per_satoshi = 10;
|
2016-01-21 21:11:49 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 21:15:27 +01:00
|
|
|
static void check_config(struct lightningd_state *dstate)
|
|
|
|
{
|
2016-03-24 02:39:41 +01:00
|
|
|
/* BOLT #2:
|
|
|
|
* The sender MUST set `close_fee` lower than or equal to the
|
2016-05-02 08:28:56 +02:00
|
|
|
* fee of the final commitment transaction
|
2016-03-24 02:39:41 +01:00
|
|
|
*/
|
2016-03-24 02:42:43 +01:00
|
|
|
|
|
|
|
/* We do this by ensuring it's less than the minimum we would accept. */
|
|
|
|
if (dstate->config.closing_fee_rate > dstate->config.commitment_fee_rate_min)
|
|
|
|
fatal("Closing fee rate %"PRIu64
|
|
|
|
" can't exceed minimum commitment fee rate %"PRIu64,
|
|
|
|
dstate->config.closing_fee_rate,
|
|
|
|
dstate->config.commitment_fee_rate_min);
|
|
|
|
|
|
|
|
if (dstate->config.commitment_fee_rate_min
|
|
|
|
> dstate->config.commitment_fee_rate)
|
|
|
|
fatal("Minumum fee rate %"PRIu64
|
|
|
|
" can't exceed commitment fee rate %"PRIu64,
|
|
|
|
dstate->config.commitment_fee_rate_min,
|
|
|
|
dstate->config.commitment_fee_rate);
|
2016-05-04 08:42:50 +02:00
|
|
|
|
|
|
|
if (dstate->config.forever_confirms < 100)
|
|
|
|
log_unusual(dstate->base_log,
|
|
|
|
"Warning: forever-confirms of %u is less than 100!",
|
|
|
|
dstate->config.forever_confirms);
|
2016-07-01 03:49:28 +02:00
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
*
|
|
|
|
* a node MUST estimate the deadline for successful redemption
|
|
|
|
* for each HTLC it offers. A node MUST NOT offer a HTLC
|
|
|
|
* after this deadline */
|
|
|
|
if (dstate->config.deadline_blocks >= dstate->config.min_htlc_expiry)
|
|
|
|
fatal("Deadline %u can't be more than minimum expiry %u",
|
|
|
|
dstate->config.deadline_blocks,
|
|
|
|
dstate->config.min_htlc_expiry);
|
2016-01-21 21:15:27 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
static struct lightningd_state *lightningd_state(void)
|
|
|
|
{
|
2016-01-21 21:11:49 +01:00
|
|
|
struct lightningd_state *dstate = tal(NULL, struct lightningd_state);
|
|
|
|
|
|
|
|
dstate->log_record = new_log_record(dstate, 20*1024*1024, LOG_INFORM);
|
|
|
|
dstate->base_log = new_log(dstate, dstate->log_record,
|
|
|
|
"lightningd(%u):", (int)getpid());
|
|
|
|
|
|
|
|
list_head_init(&dstate->peers);
|
2016-01-21 21:15:28 +01:00
|
|
|
timers_init(&dstate->timers, controlled_time());
|
2016-01-21 21:11:49 +01:00
|
|
|
txwatch_hash_init(&dstate->txwatches);
|
|
|
|
txowatch_hash_init(&dstate->txowatches);
|
|
|
|
dstate->secpctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
|
|
|
|
| SECP256K1_CONTEXT_SIGN);
|
|
|
|
default_config(&dstate->config);
|
2016-01-21 21:11:49 +01:00
|
|
|
list_head_init(&dstate->bitcoin_req);
|
2016-04-12 05:37:03 +02:00
|
|
|
list_head_init(&dstate->wallet);
|
2016-06-28 23:19:20 +02:00
|
|
|
list_head_init(&dstate->payments);
|
2016-06-30 01:38:10 +02:00
|
|
|
dstate->dev_never_routefail = false;
|
2016-01-21 21:11:49 +01:00
|
|
|
dstate->bitcoin_req_running = false;
|
2016-06-28 23:19:21 +02:00
|
|
|
dstate->nodes = empty_node_map(dstate);
|
2016-01-21 21:11:49 +01:00
|
|
|
return dstate;
|
2016-01-21 21:11:47 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
/* Tal wrappers for opt. */
|
|
|
|
static void *opt_allocfn(size_t size)
|
|
|
|
{
|
|
|
|
return tal_alloc_(NULL, size, false, TAL_LABEL("opt_allocfn", ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *tal_reallocfn(void *ptr, size_t size)
|
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
return opt_allocfn(size);
|
|
|
|
tal_resize_(&ptr, 1, size, false);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tal_freefn(void *ptr)
|
|
|
|
{
|
|
|
|
tal_free(ptr);
|
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-01-21 21:11:49 +01:00
|
|
|
struct lightningd_state *dstate = lightningd_state();
|
2016-01-21 21:11:48 +01:00
|
|
|
unsigned int portnum = 0;
|
2016-01-21 21:11:47 +01:00
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
err_set_progname(argv[0]);
|
|
|
|
opt_set_alloc(opt_allocfn, tal_reallocfn, tal_freefn);
|
|
|
|
|
2016-03-15 07:39:42 +01:00
|
|
|
if (!streq(protobuf_c_version(), PROTOBUF_C_VERSION))
|
|
|
|
errx(1, "Compiled against protobuf %s, but have %s",
|
|
|
|
PROTOBUF_C_VERSION, protobuf_c_version());
|
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
|
|
|
"\n"
|
|
|
|
"A bitcoin lightning daemon.",
|
|
|
|
"Print this message.");
|
2016-01-21 21:11:48 +01:00
|
|
|
opt_register_arg("--port", opt_set_uintval, NULL, &portnum,
|
|
|
|
"Port to bind to (otherwise, dynamic port is used)");
|
2016-03-15 07:38:40 +01:00
|
|
|
opt_register_arg("--bitcoin-datadir", opt_set_charp, NULL,
|
|
|
|
&bitcoin_datadir,
|
|
|
|
"-datadir arg for bitcoin-cli");
|
2016-01-21 21:11:49 +01:00
|
|
|
opt_register_logging(dstate->base_log);
|
2016-01-21 21:11:47 +01:00
|
|
|
opt_register_version();
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
configdir_register_opts(dstate,
|
|
|
|
&dstate->config_dir, &dstate->rpc_filename);
|
|
|
|
config_register_opts(dstate);
|
2016-01-21 21:11:48 +01:00
|
|
|
|
|
|
|
/* Get any configdir options first. */
|
|
|
|
opt_early_parse(argc, argv, opt_log_stderr_exit);
|
|
|
|
|
|
|
|
/* Move to config dir, to save ourselves the hassle of path manip. */
|
2016-01-21 21:11:49 +01:00
|
|
|
if (chdir(dstate->config_dir) != 0) {
|
|
|
|
log_unusual(dstate->base_log, "Creating lightningd dir %s"
|
2016-01-21 21:11:48 +01:00
|
|
|
" (because chdir gave %s)",
|
2016-01-21 21:11:49 +01:00
|
|
|
dstate->config_dir, strerror(errno));
|
|
|
|
if (mkdir(dstate->config_dir, 0700) != 0)
|
2016-01-21 21:11:48 +01:00
|
|
|
fatal("Could not make directory %s: %s",
|
2016-01-21 21:11:49 +01:00
|
|
|
dstate->config_dir, strerror(errno));
|
|
|
|
if (chdir(dstate->config_dir) != 0)
|
2016-01-21 21:11:48 +01:00
|
|
|
fatal("Could not change directory %s: %s",
|
2016-01-21 21:11:49 +01:00
|
|
|
dstate->config_dir, strerror(errno));
|
2016-01-21 21:11:48 +01:00
|
|
|
}
|
|
|
|
/* Activate crash log now we're in the right place. */
|
2016-01-21 21:11:49 +01:00
|
|
|
crashlog_activate(dstate->base_log);
|
2016-01-21 21:11:48 +01:00
|
|
|
|
|
|
|
/* Now look for config file */
|
2016-01-21 21:11:49 +01:00
|
|
|
opt_parse_from_config(dstate);
|
2016-01-21 21:11:48 +01:00
|
|
|
|
2016-01-21 21:11:47 +01:00
|
|
|
opt_parse(&argc, argv, opt_log_stderr_exit);
|
|
|
|
if (argc != 1)
|
|
|
|
errx(1, "no arguments accepted");
|
|
|
|
|
2016-01-21 21:15:27 +01:00
|
|
|
check_config(dstate);
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
check_bitcoind_config(dstate);
|
|
|
|
|
2016-01-21 21:11:48 +01:00
|
|
|
/* Set up node ID and private key. */
|
2016-01-21 21:11:49 +01:00
|
|
|
secrets_init(dstate);
|
2016-06-30 01:38:11 +02:00
|
|
|
new_node(dstate, &dstate->id);
|
|
|
|
|
2016-04-24 12:07:13 +02:00
|
|
|
/* Initialize block topology. */
|
|
|
|
setup_topology(dstate);
|
|
|
|
|
2016-08-09 05:41:24 +02:00
|
|
|
/* Create RPC socket (if any) */
|
|
|
|
setup_jsonrpc(dstate, dstate->rpc_filename);
|
|
|
|
|
|
|
|
/* Set up connections from peers. */
|
|
|
|
setup_listeners(dstate, portnum);
|
|
|
|
|
2016-01-21 21:15:28 +01:00
|
|
|
/* Make sure we use the artificially-controlled time for timers */
|
|
|
|
io_time_override(controlled_time);
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
log_info(dstate->base_log, "Hello world!");
|
2016-01-21 21:11:48 +01:00
|
|
|
|
2016-01-21 21:15:28 +01:00
|
|
|
for (;;) {
|
|
|
|
struct timer *expired;
|
|
|
|
void *v = io_loop(&dstate->timers, &expired);
|
2016-01-21 21:11:48 +01:00
|
|
|
|
2016-01-21 21:15:28 +01:00
|
|
|
/* We use io_break(dstate) to shut down. */
|
|
|
|
if (v == dstate)
|
|
|
|
break;
|
|
|
|
|
2016-05-09 22:56:09 +02:00
|
|
|
if (expired)
|
|
|
|
timer_expired(dstate, expired);
|
2016-06-30 01:38:11 +02:00
|
|
|
else
|
|
|
|
cleanup_peers(dstate);
|
2016-01-21 21:11:48 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 21:11:49 +01:00
|
|
|
tal_free(dstate);
|
2016-01-21 21:11:47 +01:00
|
|
|
opt_free_table();
|
2016-01-21 21:11:47 +01:00
|
|
|
return 0;
|
|
|
|
}
|