[c-lightning] [Lightning-dev] lookupinvoice

ZmnSCPxj ZmnSCPxj at protonmail.com
Wed Nov 28 14:32:34 AEDT 2018


Good morning Sarat,

Do note that due to a bug, recent c-lightning cannot process further commands on the same JSON-RPC connection if one command is waiting.
This bug does not exist in 0.6.0, I am uncertain when it got in, but 0.6.2 has this bug.
Workaround is to have a separate JSON-RPC connection to perform `waitanyinvoice` on.
Alternately, if you are using `lightning-cli` it creates a new JSON-RPC connection each time and you will be unaffected by this bug.

Regards,
ZmnSCPxj

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 27, 2018 11:58 AM, Sarat G <sarath.ginjupalli89 at gmail.com> wrote:

> Thank you very much for the information provided.
>
> Hi Rusty,
> Yes, listinvoices 'label' is working fine.
>
>  Hi  ZmnSCPxj,
> Right now, I'm maintaining state with global static variables, yes I'll use sqlite to save the state information in the coming days.
>
> Thank You.
> Regards,
> Sarat G
>
> On Tue, Nov 27, 2018 at 5:22 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
>
>> Good morning Sarat,
>>
>> The more idiomatic way is to use waitanyinvoice as an async call. You start with a pay_index of 0 that you store on disk. When waitanyinvoice returns, you trigger what needs to be called based on the invoice it returns, and once you have finished processing, update the entire ondisk state including pay_index, then call waitanyinvoice again async.
>>
>> This will scale better with hundreds of invoices and allow for recovery in case of crash or power outage. Generally you will store your state ondisk with sqlite, and put invoice processing and the pay_index update in a single sqlite atomic transaction, so that update of pay_index is dobe atomically with reacting to invoice payment.
>>
>> Regards,
>> ZmnSCPxj
>>
>> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Monday, November 26, 2018 5:24 PM, Sarat G <sarath.ginjupalli89 at gmail.com> wrote:
>>
>>> Hi  ZmnSCPxj,
>>>
>>> Good Morning, thanks for the information.
>>>
>>> So far I'm only looking at the listpayments to see whether the invoice get paid or not and I overlooked the "status" label in the listinvoices. Now I can use listinvoices to check whether the invoice got paid or not.
>>>
>>> To brief out my project, I'm developing the betting game application(https://github.com/sg777/bet) where I'm using C-LN. I'm using the main loop, but my game state machine logic depends on the status of the invoice to make further calls.
>>>
>>> Thanks again.
>>>
>>> Regards,
>>> Sarat G
>>>
>>> On Mon, Nov 26, 2018 at 2:41 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
>>>
>>>> Good morning Sarat,
>>>>
>>>> If you need to poll, `listinvoices label` will return an object with `status` field.
>>>> This field will be string `paid` if already paid.
>>>>
>>>> However, I am uncertain if you should be using such polling.
>>>> Do you not use a mainloop for your receiver, and use a JSON-RPC library or language that lets you perform the RPC asynchronously?
>>>>
>>>> All of the `wait*` commands are intended for asynchronous RPC invocations.
>>>>
>>>> In addition, this is more on-topic for c-lightning list.  I have moved this topic to C-lightning list.
>>>>
>>>> Regards,
>>>> ZmnSCPxj
>>>>
>>>> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>>>>
>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>> On Monday, November 26, 2018 4:54 PM, Sarat G <sarath.ginjupalli89 at gmail.com> wrote:
>>>>
>>>>> Hi Rusty,
>>>>>
>>>>> Thanks for your reply.
>>>>>
>>>>> I'm using the C lightning repo for my project(https://github.com/ElementsProject/lightning). Sorry, I framed the question wrongly. Yes, I can use listinvoices to look up for the invoices created at the node.
>>>>>
>>>>> My scenario is something like this, I'm looking up whether an invoice gets paid or not at the receiver end. For that at this point, I'm calling waitinvoice to see whether an invoice gets paid or not. I would like to know is there any way that the receiver could be aware that the particular invoice created by it paid or not.
>>>>>
>>>>> The problem is using waitinvoice in my case, it's making my process hang till the invoice gets paid. Some workaround which I'm using for this problem is I'm looking up the difference in amount of the label "msatoshi_to_us" while running the listpeers command.
>>>>>
>>>>> Thank You.
>>>>>
>>>>> Regards,
>>>>> Sarat G
>>>>>
>>>>> On Mon, Nov 26, 2018 at 8:59 AM Rusty Russell <rusty at rustcorp.com.au> wrote:
>>>>>
>>>>>> Sarat G <sarath.ginjupalli89 at gmail.com> writes:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm been working on the LN repo for a while now. I would like to know if
>>>>>>> there is any way that a payee can lookup the invoice it gets paid, i.e
>>>>>>> similar to the 'lookupinvoice' command as provided by the lnd(Golang).
>>>>>>
>>>>>> Hi Sarat,
>>>>>>
>>>>>>         I'm confused; "the LN repo" is ambigious, as there are several,
>>>>>> each with their own places to ask questions:
>>>>>>
>>>>>> https://github.com/ACINQ/eclair-wallet/
>>>>>> https://github.com/ElementsProject/lightning
>>>>>> https://github.com/LightningNetwork/lnd/
>>>>>> https://github.com/nayutaco/ptarmigan
>>>>>> https://github.com/rust-bitcoin/rust-lightning
>>>>>>
>>>>>> Then of course there's the spec repo as well, which guides us all:
>>>>>>
>>>>>>         https://github.com/lightningnetwork/lightning-rfc
>>>>>>
>>>>>> But AFAICT (though your question is off-topic for this list):
>>>>>>
>>>>>>         lnd has lookupinvoice which looks up by hash[1]
>>>>>>         eclair has checkpayment which looks up by hash or bolt11[2]
>>>>>>         c-lightning has listinvoices which can lookup by label[3], or
>>>>>>            wait(any)invoice[4] which is used for polling.
>>>>>>
>>>>>> Would love someone to write a rosetta stone for the different APIs!
>>>>>>
>>>>>> Cheers,
>>>>>> Rusty.
>>>>>>
>>>>>> [1] https://api.lightning.community/#lookupinvoice
>>>>>> [2] https://github.com/ACINQ/eclair/wiki/API
>>>>>> [3] https://github.com/ElementsProject/lightning/blob/master/doc/lightning-listinvoices.7.txt
>>>>>> [4] https://github.com/ElementsProject/lightning/blob/master/doc/lightning-waitanyinvoice.7.txt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/c-lightning/attachments/20181128/a7566f5c/attachment.html>


More information about the c-lightning mailing list