From 61383408a45960bf7fd045fc420c95478de699c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Wed, 25 Sep 2019 19:16:43 +0200 Subject: [PATCH] pay: Return error when trying to pay to an invoice from unkown or different chain --- plugins/pay.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/pay.c b/plugins/pay.c index d524611e8..6b0dfc1e5 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1043,6 +1043,14 @@ static struct command_result *json_pay(struct command *cmd, "Invalid bolt11: %s", fail); } + if (!b11->chain) { + return command_fail(cmd, PAY_ROUTE_NOT_FOUND, "Invoice is for an unknown network"); + } + + if (b11->chain != chainparams) { + return command_fail(cmd, PAY_ROUTE_NOT_FOUND, "Invoice is for another network %s", b11->chain->network_name); + } + if (time_now().ts.tv_sec > b11->timestamp + b11->expiry) { return command_fail(cmd, PAY_INVOICE_EXPIRED, "Invoice expired"); }