lightningd: split invoice check into separate function.

We now return the same error for various "does not match this
invoice", so it makes sense to encapsulate these checks.  We'll also
want to expose this for multi-part payments.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-12-12 10:25:45 +10:30
committed by Christian Decker
parent 8b129b439b
commit 7f629e545e
2 changed files with 69 additions and 44 deletions

View File

@@ -8,6 +8,24 @@ struct htlc_in;
struct lightningd;
struct sha256;
/**
* invoice_check_payment - check if this payment would be valid
* @ctx: tal context to allocate return off
* @ld: lightningd
* @payment_hash: hash of preimage they want.
* @msat: amount they offer to pay.
* @payment_secret: they payment secret they sent, if any.
*
* Returns NULL if there's a problem, otherwise returns the invoice details.
*/
const struct invoice_details *
invoice_check_payment(const tal_t *ctx,
struct lightningd *ld,
const struct sha256 *payment_hash,
const struct amount_msat msat,
const struct secret *payment_secret);
/**
* invoice_try_pay - process payment for this payment_hash, amount msat.
* @ld: lightningd