lightningd: create new return code for enableoffer.

Suggested-by: https://github.com/Lagrang3
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-08-09 14:57:50 +09:30
parent 1e1edfd073
commit 975dd76086
5 changed files with 15 additions and 2 deletions

View File

@ -112,6 +112,7 @@ enum jsonrpc_errcode {
OFFER_ROUTE_NOT_FOUND = 1003,
OFFER_BAD_INVREQ_REPLY = 1004,
OFFER_TIMEOUT = 1005,
OFFER_ALREADY_ENABLED = 1006,
/* Errors from datastore command */
DATASTORE_DEL_DOES_NOT_EXIST = 1200,

View File

@ -10998,6 +10998,12 @@
"Note: the returned object is the same format as **listoffers**."
]
},
"errors": [
"On failure, one of the following error codes may be returned:",
"",
"- -32602: Error in given parameters.",
"- 1006: offer already enabled."
],
"author": [
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
],

View File

@ -74,6 +74,12 @@
"Note: the returned object is the same format as **listoffers**."
]
},
"errors": [
"On failure, one of the following error codes may be returned:",
"",
"- -32602: Error in given parameters.",
"- 1006: offer already enabled."
],
"author": [
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
],

View File

@ -253,7 +253,7 @@ static struct command_result *json_enableoffer(struct command *cmd,
return command_fail(cmd, LIGHTNINGD, "Unknown offer");
if (offer_status_active(status))
return command_fail(cmd, OFFER_ALREADY_DISABLED,
return command_fail(cmd, OFFER_ALREADY_ENABLED,
"offer already active");
if (command_check_only(cmd))

View File

@ -5990,7 +5990,7 @@ def test_enableoffer(node_factory):
l1.rpc.fetchinvoice(offer=offer1['bolt12'])
# Can't enable twice.
with pytest.raises(RpcError, match="1001.*offer already active"):
with pytest.raises(RpcError, match="1006.*offer already active"):
l2.rpc.enableoffer(offer_id=offer1['offer_id'])
# Can't enable unknown.