From ca7864f2f300e8ba8023e6824655cee1376d1828 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 16 Apr 2019 09:46:22 +0930 Subject: [PATCH] invoice_hook: remove nested result. I misunderstood the API, this ended up nesting a result inside the JSON-RPC result. No concerns about backwards compatibility since this is so new. Signed-off-by: Rusty Russell --- lightningd/invoice.c | 10 ++-------- tests/plugins/reject_some_invoices.py | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lightningd/invoice.c b/lightningd/invoice.c index cbb09cf07..b6365c5ad 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -141,23 +141,17 @@ static bool hook_gives_failcode(const char *buffer, const jsmntok_t *toks, enum onion_type *failcode) { - const jsmntok_t *resulttok, *t; + const jsmntok_t *t; unsigned int val; /* No plugin registered on hook at all? */ if (!buffer) return false; - resulttok = json_get_member(buffer, toks, "result"); - if (!resulttok) - fatal("Invalid invoice_payment_hook response: %.*s", - toks[0].end - toks[1].start, buffer); - - t = json_get_member(buffer, resulttok, "failure_code"); + t = json_get_member(buffer, toks, "failure_code"); if (!t) return false; - if (!json_to_number(buffer, t, &val)) fatal("Invalid invoice_payment_hook failure_code: %.*s", toks[0].end - toks[1].start, buffer); diff --git a/tests/plugins/reject_some_invoices.py b/tests/plugins/reject_some_invoices.py index 6f520effd..99ac6103e 100755 --- a/tests/plugins/reject_some_invoices.py +++ b/tests/plugins/reject_some_invoices.py @@ -18,9 +18,9 @@ def on_payment(payment, plugin): if payment['preimage'].endswith('0'): # FIXME: Define this! WIRE_TEMPORARY_NODE_FAILURE = 0x2002 - return {'result': {'failure_code': WIRE_TEMPORARY_NODE_FAILURE}} + return {'failure_code': WIRE_TEMPORARY_NODE_FAILURE} - return {'result': {}} + return {} plugin.run()