From 351718e90ff47a79fbe3ce2a77cbdc4de209f54c Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 12 Jan 2018 19:40:09 +0100 Subject: [PATCH] jsonrpc: Return an error if funding amount is too large Fixes #516 Reported-by: @instagibbs Signed-off-by: Christian Decker --- lightningd/peer_control.c | 5 +++++ lightningd/peer_control.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 2de0b7c5a..024c61fe7 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2559,6 +2559,11 @@ static void json_fund_channel(struct command *cmd, return; } + if (fc->funding_satoshi >= MAX_FUNDING_MSATOSHI) { + command_fail(cmd, "Funding msatoshi must be < %d", MAX_FUNDING_MSATOSHI); + return; + } + /* FIXME: Support push_msat? */ fc->push_msat = 0; diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index 31d8640b2..24c94f9ee 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -14,6 +14,7 @@ #include #define ANNOUNCE_MIN_DEPTH 6 +#define MAX_FUNDING_MSATOSHI (1 << 24) struct crypto_state;