Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,8 @@
},
"ListoffersRequest": {
"ListOffers.active_only": 2,
"ListOffers.offer_id": 1
"ListOffers.offer_id": 1,
"ListOffers.usable_only": 3
},
"ListoffersResponse": {
"ListOffers.offers[]": 1
Expand Down Expand Up @@ -10600,6 +10601,10 @@
"added": "pre-v0.10.1",
"deprecated": null
},
"ListOffers.usable_only": {
"added": "v26.04",
"deprecated": null
},
"ListPays": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
1 change: 1 addition & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23271,6 +23271,12 @@
"description": [
"If set and is true, only offers with `active` true are returned."
]
},
"usable_only": {
"type": "boolean",
"description": [
"If set and is true, only offers that can be either used multiple times or that have not been used yet are returned."
]
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion contrib/pyln-client/pyln/client/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def listnodes(self, node_id=None):
}
return self.call("listnodes", payload)

def listoffers(self, offer_id=None, active_only=None):
def listoffers(self, offer_id=None, active_only=None, usable_only=None):
"""List offers

List all offers, or with {offer_id}, only the offer with that {offer_id} (if it exists).
Expand All @@ -1032,6 +1032,7 @@ def listoffers(self, offer_id=None, active_only=None):
payload = {
"offer_id": offer_id,
"active_only": active_only,
"usable_only": usable_only,
}
return self.call("listoffers", payload)

Expand Down
1,298 changes: 649 additions & 649 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions doc/schemas/listoffers.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"description": [
"If set and is true, only offers with `active` true are returned."
]
},
"usable_only": {
"type": "boolean",
"description": [
"If set and is true, only offers that can be either used multiple times or that have not been used yet are returned."
]
}
}
},
Expand Down
10 changes: 8 additions & 2 deletions lightningd/offer.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ static struct command_result *json_listoffers(struct command *cmd,
const char *description;
const struct json_escape *label;
bool *active_only;
bool *usable_only;
enum offer_status status;

if (!param(cmd, buffer, params,
p_opt("offer_id", param_sha256, &offer_id),
p_opt_def("active_only", param_bool, &active_only, false),
p_opt_def("usable_only", param_bool, &usable_only, false),
NULL))
return command_param_failed();

Expand All @@ -170,7 +172,9 @@ static struct command_result *json_listoffers(struct command *cmd,
if (offer_id) {
b12 = wallet_offer_find(tmpctx, wallet, offer_id, &label,
&status);
if (b12 && offer_status_active(status) >= *active_only) {
if (b12 && offer_status_active(status) >= *active_only &&
(offer_status_single(status) == 0 ||
offer_status_used(status) == 0) >= *usable_only) {
json_object_start(response, NULL);
json_populate_offer(response,
offer_id, b12,
Expand All @@ -189,7 +193,9 @@ static struct command_result *json_listoffers(struct command *cmd,
stmt = wallet_offer_id_next(cmd->ld->wallet, stmt, &id)) {
b12 = wallet_offer_find(tmpctx, wallet, &id,
&label, &status);
if (offer_status_active(status) >= *active_only) {
if (offer_status_active(status) >= *active_only &&
(offer_status_single(status) == 0 ||
offer_status_used(status) == 0) >= *usable_only) {
json_object_start(response, NULL);
json_populate_offer(response,
&id, b12,
Expand Down
Loading