From a90502d917815fb8d5e5a6ef583491b1526526e6 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 28 Feb 2018 23:24:58 +0100 Subject: [PATCH] jsonrpc: Refuse to forget a channel with an open HTLC ... instead provide useful suggestions as to how to close it. Signed-off-by: Christian Decker --- lightningd/peer_control.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 5c8ebcbfc..97bf9d84a 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1086,6 +1086,15 @@ static void json_dev_forget_channel(struct command *cmd, const char *buffer, return; } + if (channel_has_htlc_out(forget->channel) || + channel_has_htlc_in(forget->channel)) { + command_fail(cmd, "This channel has HTLCs attached and it is " + "not safe to forget it. Please use `close` " + "or `dev-fail` instead."); + return; + + } + bitcoind_gettxout(cmd->ld->topology->bitcoind, &forget->channel->funding_txid, forget->channel->funding_outnum,