invoice: include invoice label to wait subsystem when it's paid.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-07-22 17:16:18 +09:30
parent 6782c2fef5
commit bbf4f312a4
5 changed files with 11 additions and 9 deletions

View File

@ -315,7 +315,8 @@ invoice_payment_hooks_done(struct invoice_payment_hook_payload *payload STEALS)
}
/* Paid or expired in the meantime. */
if (!invoices_resolve(ld->wallet->invoices, inv_dbid, payload->msat)) {
if (!invoices_resolve(ld->wallet->invoices, inv_dbid, payload->msat,
payload->label)) {
htlc_set_fail(payload->set, take(failmsg_incorrect_or_unknown(
NULL, ld, payload->set->htlcs[0])));
return;

View File

@ -414,7 +414,8 @@ struct db_stmt *invoices_next(struct invoices *invoices UNNEEDED,
/* Generated stub for invoices_resolve */
bool invoices_resolve(struct invoices *invoices UNNEEDED,
u64 inv_dbid UNNEEDED,
struct amount_msat received UNNEEDED)
struct amount_msat received UNNEEDED,
const struct json_escape *label UNNEEDED)
{ fprintf(stderr, "invoices_resolve called!\n"); abort(); }
/* Generated stub for invoices_waitany */
void invoices_waitany(const tal_t *ctx UNNEEDED,

View File

@ -744,9 +744,7 @@ def test_wait_invoices(node_factory, executor):
waitres = waitfut.result(TIMEOUT)
assert waitres == {'subsystem': 'invoices',
'updated': 1,
# FIXME: fill in details!
# {'label': 'invlabel', 'bolt11': inv['bolt11'], 'status': 'paid'}
'details': {'status': 'paid'}}
'details': {'label': 'invlabel', 'status': 'paid'}}
# Second returns instantly, without any details.
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'updated', 'nextvalue': 1})

View File

@ -545,7 +545,8 @@ static void maybe_mark_offer_used(struct db *db, u64 inv_dbid)
bool invoices_resolve(struct invoices *invoices,
u64 inv_dbid,
struct amount_msat received)
struct amount_msat received,
const struct json_escape *label)
{
struct db_stmt *stmt;
s64 pay_index;
@ -571,10 +572,9 @@ bool invoices_resolve(struct invoices *invoices,
db_bind_u64(stmt, pay_index);
db_bind_amount_msat(stmt, &received);
db_bind_u64(stmt, paid_timestamp);
/* FIXME: populate label */
db_bind_u64(stmt,
invoice_index_update_status(invoices->wallet->ld,
NULL, PAID));
label, PAID));
db_bind_u64(stmt, inv_dbid);
db_exec_prepared_v2(take(stmt));

View File

@ -165,12 +165,14 @@ struct db_stmt *invoices_next(struct invoices *invoices,
* @invoices - the invoice handler.
* @inv_dbid - the invoice to mark as paid.
* @received - the actual amount received.
* @label - the label of the invoice.
*
* If the invoice is not UNPAID, returns false.
*/
bool invoices_resolve(struct invoices *invoices,
u64 inv_dbid,
struct amount_msat received);
struct amount_msat received,
const struct json_escape *label);
/**
* invoices_waitany - Wait for any invoice to be paid.