Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscribeToInvoice method not working #149

Open
lastcron opened this issue Oct 20, 2021 · 9 comments
Open

subscribeToInvoice method not working #149

lastcron opened this issue Oct 20, 2021 · 9 comments

Comments

@lastcron
Copy link

I Just notice that in the supported versions, Ver LND 0.13.3-beta.rc2 is not yet supported. So this is just a heads up that the subscribeToInvoice method is not working on the RC2 version , we had to use subscribeToInvoices instead. ( with an s at the end )

Also in this RC2 version the subscribeToInvoices is not reporting invoice cancellations.

Thank for such a great work.

@alexbosworth
Copy link
Owner

what doesn't work exactly about subscribeToInvoice?

@lastcron
Copy link
Author

After subscribing to the method subscribeToInvoice the event is not being fired when an invoice gets payed.

We previously had ver 13.2 working normally , the issue appeared after updating the lnd server to 0.13.3-beta.rc2.

Thanks again.

@alexbosworth
Copy link
Owner

Can you share some code? I can't reproduce a problem with subscribeToInvoice on 0.13.3-beta.rc2, I do get an event when the invoice is paid

@lastcron
Copy link
Author

lastcron commented Oct 20, 2021

import {
   payViaRoutes,
   getInvoice,
   createInvoice,
   decodePaymentRequest,
   payViaPaymentDetails,
   createInvoice as createInvoiceRequest,
   subscribeToInvoice,
   subscribeToInvoices,
   authenticatedLndGrpc,
   getChannelBalance,
 } from "ln-service";

 const { lnd } = authenticatedLndGrpc({
  cert: process.env.CERT,
  macaroon: process.env.MACAROON,
  socket: `${process.env.LNDSERVER}:10009`,
});

const newInvoice = (tokens, description) => {
    const expiresIn: Date = new Date();
    expiresIn.setSeconds(expiresIn.getSeconds() + 60);
    expiresIn.toLocaleString("UTC", {
      timeZone: "UTC",
    });
    const invoice = await createInvoiceRequest({
         lnd,
         tokens,
         description,
         expires_at: expiresIn.toISOString(),
       });
       const sub = subscribeToInvoice({ id: invoice.id, lnd });
       sub.on("invoice_updated", async (info: any) => {
           console.log(info)
       })
}
newInvoice(10000, 'MyPayment'); 

@alexbosworth
Copy link
Owner

maybe it is an ordering issue, does it work if you put the subscription before the create invoice request?

@lastcron
Copy link
Author

I need the invoice.id for the subcription. If I put the subscription before the create invoice I will not have that parameter available.

@alexbosworth
Copy link
Owner

ok yeah that makes sense

it should show updates after the creation though, maybe nothing is retaining the subscription? I don't know why it would be related to the lnd version

@jfrader
Copy link

jfrader commented Jan 20, 2024

For me the same issue using

lightning
        .subscribeToInvoice({ lnd, id })
        .on("invoice_updated", (invoice: lightning.SubscribeToInvoiceInvoiceUpdatedEvent) => {
          logger.debug(JSON.stringify(invoice))
          if (invoice.is_confirmed) {
            onConfirmed(invoice)
          }
        })

This works on LND v0.16.2-beta in SIMNET using polarlightning, but after deploying the same code to an environment with LND v0.17.3-beta in TESTNET, it is not triggering

@jfrader
Copy link

jfrader commented Jan 20, 2024

Update: After realizing I built LND from source using make install as opposed to make release-install which adds the tags needed for this method, this issue can be closed I guess. Its working in latest version v0.17.3-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants