From 06b9009dd8d2de7deaed8adee345517f8f393297 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 14 Mar 2023 15:47:50 +1030 Subject: [PATCH] lightningd: remove deprecated behavior where checkmessage would fail quietly. Signed-off-by: Rusty Russell Changelog-Removed: JSON-RPC: `checkmessage` now always returns an error when the pubkey is not specified and it is unknown in the network graph (deprecated v0.12.0) --- lightningd/signmessage.c | 7 ++++--- tests/test_misc.py | 15 +++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lightningd/signmessage.c b/lightningd/signmessage.c index 5a008a425..c7811be55 100644 --- a/lightningd/signmessage.c +++ b/lightningd/signmessage.c @@ -134,9 +134,10 @@ static void listnodes_done(const char *buffer, if (t) t = json_get_member(buffer, t, "nodes"); - if (!deprecated_apis && (!t || t->size == 0)) { - response = json_stream_fail(can->cmd, SIGNMESSAGE_PUBKEY_NOT_FOUND, - "pubkey not found in the graph"); + if (!t || t->size == 0) { + response = json_stream_fail(can->cmd, + SIGNMESSAGE_PUBKEY_NOT_FOUND, + "pubkey not found in the graph"); json_add_node_id(response, "claimed_key", &can->id); json_object_end(response); was_pending(command_failed(can->cmd, response)); diff --git a/tests/test_misc.py b/tests/test_misc.py index bd9207708..7e414251d 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2011,8 +2011,7 @@ def test_relative_config_dir(node_factory): def test_signmessage(node_factory): - l1, l2 = node_factory.line_graph(2, wait_for_announce=True, - opts={'allow-deprecated-apis': True}) + l1, l2 = node_factory.line_graph(2, wait_for_announce=True) l1.rpc.jsonschemas = {} corpus = [[None, @@ -2049,13 +2048,17 @@ def test_signmessage(node_factory): assert l1.rpc.checkmessage(c[1], c[2], c[3])['verified'] assert not l1.rpc.checkmessage(c[1] + "modified", c[2], c[3])['verified'] - checknokey = l1.rpc.checkmessage(c[1], c[2]) + # Of course, we know our own pubkey if c[3] == l1.info['id']: - assert checknokey['verified'] + assert l1.rpc.checkmessage(c[1], c[2])['verified'] else: - assert not checknokey['verified'] - assert checknokey['pubkey'] == c[3] + # It will error, as it can't verify. + with pytest.raises(RpcError, match="pubkey not found in the graph") as err: + l1.rpc.checkmessage(c[1], c[2]) + + # But error contains the key which it claims. + assert err.value.error['data']['claimed_key'] == c[3] # l2 knows about l1, so it can validate it. zm = l1.rpc.signmessage(message="message for you")['zbase']