mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
rpc: improve error format
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
committed by
Christian Decker
parent
1d671a2380
commit
7ae616ef60
@@ -29,14 +29,9 @@ RETURN VALUE
|
|||||||
|
|
||||||
[comment]: # (GENERATE-FROM-SCHEMA-START)
|
[comment]: # (GENERATE-FROM-SCHEMA-START)
|
||||||
On success, an object is returned, containing:
|
On success, an object is returned, containing:
|
||||||
- **verified** (boolean): Whether the signature was valid
|
- **verified** (boolean): whether the signature was valid (always *true*)
|
||||||
|
|
||||||
If **verified** is *true*:
|
|
||||||
- **pubkey** (pubkey): the *pubkey* parameter, or the pubkey found by looking for known nodes
|
- **pubkey** (pubkey): the *pubkey* parameter, or the pubkey found by looking for known nodes
|
||||||
|
|
||||||
If **verified** is *false*:
|
|
||||||
- **pubkey** (pubkey): the *pubkey* (if any) which could have signed this; this is usually not useful!
|
|
||||||
|
|
||||||
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
||||||
|
|
||||||
AUTHOR
|
AUTHOR
|
||||||
@@ -54,4 +49,4 @@ RESOURCES
|
|||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
|
|
||||||
[comment]: # ( SHA256STAMP:7dcca1fd1708d93b4a0c9b83955630fc4f551c4ffd452fb866c624c72aeaa44d)
|
[comment]: # ( SHA256STAMP:af2feeb4eddafc509dff150ec4b11225618f1cbbea06ef81f6d97a1bece3e94c)
|
||||||
|
|||||||
@@ -2,65 +2,21 @@
|
|||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"verified"
|
"verified",
|
||||||
|
"pubkey"
|
||||||
],
|
],
|
||||||
"additionalProperties": true,
|
"additionalProperties": false,
|
||||||
"properties": {
|
|
||||||
"verified": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Whether the signature was valid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"if": {
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"verified": {
|
"verified": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"enum": [
|
"enum": [
|
||||||
true
|
true
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"pubkey"
|
|
||||||
],
|
],
|
||||||
"properties": {
|
"description": "whether the signature was valid"
|
||||||
"verified": {},
|
},
|
||||||
"pubkey": {
|
"pubkey": {
|
||||||
"type": "pubkey",
|
"type": "pubkey",
|
||||||
"description": "the *pubkey* parameter, or the pubkey found by looking for known nodes"
|
"description": "the *pubkey* parameter, or the pubkey found by looking for known nodes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"if": {
|
|
||||||
"properties": {
|
|
||||||
"verified": {
|
|
||||||
"type": "boolean",
|
|
||||||
"enum": [
|
|
||||||
false
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"pubkey"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"verified": {},
|
|
||||||
"pubkey": {
|
|
||||||
"type": "pubkey",
|
|
||||||
"description": "the *pubkey* (if any) which could have signed this; this is usually not useful!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -135,9 +135,12 @@ static void listnodes_done(const char *buffer,
|
|||||||
t = json_get_member(buffer, t, "nodes");
|
t = json_get_member(buffer, t, "nodes");
|
||||||
|
|
||||||
if (!deprecated_apis && (!t || t->size == 0)) {
|
if (!deprecated_apis && (!t || t->size == 0)) {
|
||||||
was_pending(command_fail(can->cmd, SIGNMESSAGE_PUBKEY_NOT_FOUND,
|
struct json_stream *response;
|
||||||
"pub key not found in the graph, expected pubkey is %s",
|
response = json_stream_fail(can->cmd, SIGNMESSAGE_PUBKEY_NOT_FOUND,
|
||||||
node_id_to_hexstr(tmpctx, &can->id)));
|
"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));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response = json_stream_success(can->cmd);
|
response = json_stream_success(can->cmd);
|
||||||
|
|||||||
@@ -2722,8 +2722,11 @@ def test_checkmessage_pubkey_not_found(node_factory):
|
|||||||
pubkey = "03be3b0e9992153b1d5a6e1623670b6c3663f72ce6cf2e0dd39c0a373a7de5a3b7"
|
pubkey = "03be3b0e9992153b1d5a6e1623670b6c3663f72ce6cf2e0dd39c0a373a7de5a3b7"
|
||||||
zbase = "d66bqz3qsku5fxtqsi37j11pci47ydxa95iusphutggz9ezaxt56neh77kxe5hyr41kwgkncgiu94p9ecxiexgpgsz8daoq4tw8kj8yx"
|
zbase = "d66bqz3qsku5fxtqsi37j11pci47ydxa95iusphutggz9ezaxt56neh77kxe5hyr41kwgkncgiu94p9ecxiexgpgsz8daoq4tw8kj8yx"
|
||||||
|
|
||||||
with pytest.raises(RpcError, match="not found in the graph, expected pubkey is {}".format(pubkey)):
|
with pytest.raises(RpcError) as exception:
|
||||||
l1.rpc.checkmessage(msg, zbase)
|
l1.rpc.checkmessage(msg, zbase)
|
||||||
|
err = exception.value
|
||||||
|
assert err.error['message'] == "pubkey not found in the graph"
|
||||||
|
assert err.error['data']['claimed_key'] == pubkey
|
||||||
|
|
||||||
check_result = l1.rpc.checkmessage(msg, zbase, pubkey=pubkey)
|
check_result = l1.rpc.checkmessage(msg, zbase, pubkey=pubkey)
|
||||||
assert check_result["pubkey"] == pubkey
|
assert check_result["pubkey"] == pubkey
|
||||||
|
|||||||
Reference in New Issue
Block a user