From 9f560a94944970a3b0467b6487924c196b3bff7e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jan 2016 06:45:27 +1030 Subject: [PATCH] daemon: --closing-fee Signed-off-by: Rusty Russell --- daemon/lightningd.c | 23 +++++++++++++++++++++++ daemon/lightningd.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/daemon/lightningd.c b/daemon/lightningd.c index a2b613453..bce8c6768 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -84,6 +84,9 @@ static void config_register_opts(struct lightningd_state *dstate) opt_register_arg("--min-commit-fee", opt_set_u64, opt_show_u64, &dstate->config.commitment_fee_min, "Minimum satoshis to accept for commitment transaction fee"); + opt_register_arg("--closing-fee", opt_set_u64, opt_show_u64, + &dstate->config.closing_fee, + "Satoshis to use for mutual close transaction fee"); opt_register_arg("--bitcoind-poll", opt_set_u32, opt_show_u32, &dstate->config.poll_seconds, "Seconds between polling for new transactions"); @@ -114,9 +117,27 @@ static void default_config(struct config *config) /* Don't accept less than double the current standard fee. */ config->commitment_fee_min = 10000; + /* Use this for mutual close. */ + config->closing_fee = 10000; + config->poll_seconds = 30; } +static void check_config(struct lightningd_state *dstate) +{ + if (dstate->config.closing_fee > dstate->config.commitment_fee) + fatal("Closing fee %"PRIu64 + " can't exceed commitment fee %"PRIu64, + dstate->config.closing_fee, + dstate->config.commitment_fee); + + if (dstate->config.commitment_fee_min > dstate->config.commitment_fee) + fatal("Minumum fee %"PRIu64 + " can't exceed commitment fee %"PRIu64, + dstate->config.commitment_fee_min, + dstate->config.commitment_fee); +} + static struct lightningd_state *lightningd_state(void) { struct lightningd_state *dstate = tal(NULL, struct lightningd_state); @@ -203,6 +224,8 @@ int main(int argc, char *argv[]) if (argc != 1) errx(1, "no arguments accepted"); + check_config(dstate); + check_bitcoind_config(dstate); /* Create RPC socket (if any) */ diff --git a/daemon/lightningd.h b/daemon/lightningd.h index 2bef158cd..8713cf6d4 100644 --- a/daemon/lightningd.h +++ b/daemon/lightningd.h @@ -32,6 +32,9 @@ struct config { /* How little are we prepared to have them pay? */ u64 commitment_fee_min; + /* What fee we use for the closing transaction (satoshis) */ + u64 closing_fee; + /* How long (seconds) between polling bitcoind. */ u32 poll_seconds; };