invoices: Change iteration interface to be more abstract.

This commit is contained in:
ZmnSCPxj
2018-02-24 12:11:14 +00:00
committed by Christian Decker
parent e9112af0bc
commit f05c86618c
6 changed files with 89 additions and 28 deletions

View File

@@ -245,15 +245,15 @@ static void json_add_invoices(struct json_result *response,
const char *buffer, const jsmntok_t *label,
bool modern)
{
const struct invoice *i;
struct invoice_iterator it;
struct invoice_details details;
char *lbl = NULL;
if (label)
lbl = tal_strndup(response, &buffer[label->start], label->end - label->start);
i = NULL;
while ((i = wallet_invoice_iterate(wallet, i)) != NULL) {
wallet_invoice_details(response, wallet, i, &details);
memset(&it, 0, sizeof(it));
while (wallet_invoice_iterate(wallet, &it)) {
wallet_invoice_iterator_deref(response, wallet, &it, &details);
if (lbl && !streq(details.label, lbl))
continue;
json_add_invoice(response, &details, modern);