Skip to content

Commit

Permalink
lightningd: create new return code for enableoffer.
Browse files Browse the repository at this point in the history
Suggested-by: https://github.com/Lagrang3
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 11, 2024
1 parent 1e1edfd commit 975dd76
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/jsonrpc_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<[email protected]>> is mainly responsible."
],
Expand Down
6 changes: 6 additions & 0 deletions doc/schemas/lightning-enableoffer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<[email protected]>> is mainly responsible."
],
Expand Down
2 changes: 1 addition & 1 deletion lightningd/offer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 975dd76

Please sign in to comment.