mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
invoice: Fix waitanyinvoice
There were two bugs: we weren't returning the next from the given label but the one matching the label, and we were appending new invoices to the head instead of the tail, which meant we'd be traversing in the wrong order. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
71c090745b
commit
adfe494b08
@@ -191,7 +191,7 @@ static void json_invoice(struct command *cmd,
|
|||||||
|
|
||||||
/* OK, connect it to main state, respond with hash */
|
/* OK, connect it to main state, respond with hash */
|
||||||
tal_steal(invs, invoice);
|
tal_steal(invs, invoice);
|
||||||
list_add(&invs->invlist, &invoice->list);
|
list_add_tail(&invs->invlist, &invoice->list);
|
||||||
|
|
||||||
json_object_start(response, NULL);
|
json_object_start(response, NULL);
|
||||||
json_add_hex(response, "rhash",
|
json_add_hex(response, "rhash",
|
||||||
@@ -342,6 +342,8 @@ static void json_waitanyinvoice(struct command *cmd,
|
|||||||
command_fail(cmd, "Label not found");
|
command_fail(cmd, "Label not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* Skip this particular invoice */
|
||||||
|
i = list_next(&invs->invlist, i, list);
|
||||||
while (i && i->state == UNPAID) {
|
while (i && i->state == UNPAID) {
|
||||||
i = list_next(&invs->invlist, i, list);
|
i = list_next(&invs->invlist, i, list);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user