From bc7393bb648d8625df70c4d8e73f80f472a290a2 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 23 Jul 2018 14:46:03 +0200 Subject: [PATCH] pay: Reduce nesting and fix minor type inconsistency --- lightningd/pay.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index cef13e5c8..a75036b7c 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -1123,20 +1123,19 @@ static void json_listpayments(struct command *cmd, const char *buffer, NULL)) return; + if (rhashtok && bolt11tok) { + command_fail(cmd, JSONRPC2_INVALID_PARAMS, + "Can only specify one of" + " {bolt11} or {payment_hash}"); + return; + } + if (bolt11tok) { struct bolt11 *b11; char *b11str, *fail; - if (rhashtok) { - command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Can only specify one of" - " {bolt11} or {payment_hash}"); - return; - } - b11str = tal_strndup(cmd, buffer + bolt11tok->start, bolt11tok->end - bolt11tok->start); - b11 = bolt11_decode(cmd, b11str, NULL, &fail); if (!b11) { command_fail(cmd, JSONRPC2_INVALID_PARAMS, @@ -1160,13 +1159,15 @@ static void json_listpayments(struct command *cmd, const char *buffer, payments = wallet_payment_list(cmd, cmd->ld->wallet, rhash); json_object_start(response, NULL); + json_array_start(response, "payments"); - for (int i=0; i