LIGHTNING-WAITANYINVOICE(7)
πΈ waitanyinvoice β LIGHTNING-WAITANYINVOICE(7) πΈ
okay bestie so this is the manual page for lightning-waitanyinvoice, section 7 of the Lightning manual. yes the header says LIGHTNING-WAITANYINVOICE(7) twice, that's just how manpages roll, we don't question it. sit down, grab a strawberry π, this one's actually so useful.
πΈ NAME πΈ
waitanyinvoice β the command for waiting for payments, and honestly it does exactly what it says on the tin. no notes. π
β¨ SYNOPSIS β¨
waitanyinvoice [lastpay_index] [timeout]
π DESCRIPTION π
so the waitanyinvoice RPC command just... waits. it sits there patiently until an invoice gets paid, then returns a single entry exactly like listinvoices would. π«Ά
the important bit: it will not return for any invoices paid prior to or including the lastpay_index. that's your whole safety rail, bestie.
the way you normally use this is iteratively β iconic behavior honestly: you call it once with no arguments, then you call it again and again, each time passing in the pay_index from the entry it handed you back. this is how you make sure no paid invoice ever slips through the cracks. and pay_index? it's a monotonically-increasing number that gets assigned to an invoice the moment it gets paid. the first valid pay_index is 1. β¨
lastpay_index(u64, optional) β ignores any invoices paid prior to or including this index.0is equivalent to not specifying it at all, and a negative value is invalid (don't do it π).timeout(u64, optional) β if you specify it, the command waits at most that number of seconds, and it must be an integer. if the specified timeout is reached, this command returns with an error. you can even set it to0so thatwaitanyinvoicereturns immediately with an error if no pending invoice is available yet. if you leave it unspecified, this command will wait indefinitely β literally forever, no cap. π
π RETURN VALUE π
on success, an object is returned, containing:
label(string) β unique label supplied at invoice creation.payment_hash(hash) β the hash of thepayment_preimagewhich will prove payment.status(string) (one of"paid","expired") β whether it's paid or expired.expires_at(u64) β UNIX timestamp of when it will become / became unpayable.created_index(u64) β 1-based index indicating order this invoice was created in. (added v23.08)description(string, optional) β description used in the invoice.amount_msat(msat, optional) β the amount required to pay this invoice.bolt11(string, optional) β the BOLT11 string (always present unlessbolt12is).bolt12(string, optional) β the BOLT12 string (always present unlessbolt11is).updated_index(u64, optional) β 1-based index indicating order this invoice was changed (only present if it has changed since creation). (added v23.08)
and if status is "paid", you also get this whole extra little family of fields π₯:
pay_index(u64) β unique incrementing index for this payment.amount_received_msat(msat) β the amount actually received (could be slightly greater thanamount_msat, since clients may overpay β generous of them π).paid_at(u64) β UNIX timestamp of when it was paid.payment_preimage(secret) β proof of payment.paid_outpoint(object, optional) β outpoint this invoice was paid with. (added v23.11)txid(txid) β ID of the transaction that paid the invoice. (added v23.11)outnum(u32) β the 0-based output number of the transaction that paid the invoice. (added v23.11)
π ERRORS π
the following error codes may occur:
904β the timeout was reached without an invoice being paid.
lowkey the saddest error code. you waited, and nobody paid. it's giving ghosted. π»
π AUTHOR π
Rusty Russell rusty@rustcorp.com.au is mainly responsible. absolute main character energy, we stan. π
π¦ SEE ALSO π¦
lightning-waitinvoice(7), lightning-listinvoices(7), lightning-delinvoice(7), lightning-invoice(7)
β RESOURCES β
main web site: https://github.com/ElementsProject/lightning
π§ EXAMPLES π§
Example 1
request:
$ lightning-cli waitanyinvoice
{
"id": "example:waitanyinvoice#1",
"method": "waitanyinvoice",
"params": {}
}
response:
{
"label": "lbl balance l1 to l2",
"bolt11": "lnbcrt222n1pnt3005720bolt114000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",
"payment_hash": "paymenthashdelpay10101010101010101010101010101010101010101010101",
"amount_msat": 500000000,
"status": "paid",
"pay_index": 1,
"amount_received_msat": 500000000,
"paid_at": 1738500000,
"payment_preimage": "paymentpreimgdp1010101010101010101010101010101010101010101010101",
"description": "description send some sats l1 to l2",
"expires_at": 1739000000,
"created_index": 1,
"updated_index": 1
}
Example 2
request:
$ lightning-cli waitanyinvoice -k "lastpay_index"=1 "timeout"=0
{
"id": "example:waitanyinvoice#2",
"method": "waitanyinvoice",
"params": {
"lastpay_index": 1,
"timeout": 0
}
}
response:
{
"label": "test_injectpaymentonion1",
"bolt11": "lnbcrt100n1pnt2bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000bolt11invl020700000000",
"payment_hash": "paymenthashinvl0270027002700270027002700270027002700270027002700",
"amount_msat": 1000,
"status": "paid",
"pay_index": 2,
"amount_received_msat": 1000,
"paid_at": 1738500000,
"payment_preimage": "paymentpreimgio1030303030303030303030303030303030303030303030303",
"description": "test injectpaymentonion1 description",
"expires_at": 1739000000,
"created_index": 8,
"updated_index": 2
}
and that's the whole page bestie!! π this beauty ships with Core Lightning v26.06.9, dated with the LIGHTNING-WAITANYINVOICE(7) footer stamp β go get those payments, love you, bye! πβ¨π¦
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms