From 94adbd241da9315e9d9b3f75c5141d8253a1ffdb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 14 Nov 2016 11:46:09 +1030 Subject: [PATCH] json_connect: don't try to double-fail if amount insufficient. Closes: #87 Signed-off-by: Rusty Russell --- daemon/peer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/peer.c b/daemon/peer.c index d03bec2c1..27d25a75c 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -3168,9 +3168,11 @@ static void json_connect(struct command *cmd, /* FIXME: This is normal case, not exact. */ fee = fee_by_feerate(94 + 1+73 + 1+33 + 1, get_feerate(cmd->dstate)); - if (fee >= connect->input->in_amount) + if (fee >= connect->input->in_amount) { command_fail(cmd, "Amount %"PRIu64" below fee %"PRIu64, connect->input->in_amount, fee); + return; + } connect->input->out_amount = connect->input->in_amount - fee; if (anchor_too_large(connect->input->out_amount)) {