@@ -157,11 +157,13 @@ static struct command_result *json_listoffers(struct command *cmd,
157157 const char * description ;
158158 const struct json_escape * label ;
159159 bool * active_only ;
160+ bool * usable_only ;
160161 enum offer_status status ;
161162
162163 if (!param (cmd , buffer , params ,
163164 p_opt ("offer_id" , param_sha256 , & offer_id ),
164165 p_opt_def ("active_only" , param_bool , & active_only , false),
166+ p_opt_def ("usable_only" , param_bool , & usable_only , false),
165167 NULL ))
166168 return command_param_failed ();
167169
@@ -170,7 +172,9 @@ static struct command_result *json_listoffers(struct command *cmd,
170172 if (offer_id ) {
171173 b12 = wallet_offer_find (tmpctx , wallet , offer_id , & label ,
172174 & status );
173- if (b12 && offer_status_active (status ) >= * active_only ) {
175+ if (b12 && offer_status_active (status ) >= * active_only &&
176+ (offer_status_single (status ) == 0 ||
177+ offer_status_used (status ) == 0 ) >= * usable_only ) {
174178 json_object_start (response , NULL );
175179 json_populate_offer (response ,
176180 offer_id , b12 ,
@@ -189,7 +193,9 @@ static struct command_result *json_listoffers(struct command *cmd,
189193 stmt = wallet_offer_id_next (cmd -> ld -> wallet , stmt , & id )) {
190194 b12 = wallet_offer_find (tmpctx , wallet , & id ,
191195 & label , & status );
192- if (offer_status_active (status ) >= * active_only ) {
196+ if (offer_status_active (status ) >= * active_only &&
197+ (offer_status_single (status ) == 0 ||
198+ offer_status_used (status ) == 0 ) >= * usable_only ) {
193199 json_object_start (response , NULL );
194200 json_populate_offer (response ,
195201 & id , b12 ,
0 commit comments