No new notification is received via the /v1/invoices/subscribe API for duplicated invoice payments #6797
-
BackgroundI'm working on a project that integrates with the LND REST API to, among other things, monitor payed invoices.
This simple flow works fine, the problem happens when the same invoice is payed twice. If that happens we will only receive a notification via the /v1/invoices/subscribe API that an invoice was settled for the first payment. Your environment
Steps to reproduceI'm able to replicate this use case relatively easy, the steps are:
This is also a problem for other wallets like the Blue Wallet + LND Hub.
Both payments succeed but inside the Blue Wallet the balance doesn't reflect accordingly, the second payment is "lost" (stays in LND only) and doesn't reach the Blue Wallet (I believe the reason could be connected to this problem, most likely Blue Wallet is not notified of the second payment) Expected behaviourI was expected to be notified of all payments, even duplicated ones, but that doesn't seem to happen. If you think adding a notification for the second payment doesn't make sense what about adding a configuration to LND to instead of silently accepting the second payment reject it instead? Actual behaviourNo new notification is received via the /v1/invoices/subscribe API for duplicated invoice payments. Any questions please ask. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
Hello @AzulPretoBranco I think that by default if you try to pay the same invoice twice you will get an error But that's your node playing nice. Bolt11 Invoices should not be payed more than once. If the user shares it with 100 people, and 3 of them pay it, you have no way to know who those three are. Paying the same invoice twice is not recommended. If I am one of the hops in the middle, I already saw the preimage for that invoice, which means that if the second payment goes through me I can take the full payment without having to forward it (i would be able to claim the htlc that the previous hop opened to me without having to create an htlc to the next hop) There are some invoices designed to be paid multiple times (AMP for example) but for what you specify this is not the case. Are you using your own node with lndhub on top of it or you are using the one from the bluewallet team? |
Beta Was this translation helpful? Give feedback.
-
Hi @positiveblue, thanks for the answer,
Yes, I understand and agree with this, nevertheless, it is still technically possible, hence may question about whether or not we should receive a notification for the second payment.
Correct, I'm not using AMP invoices, I'm using the regular "normal" invoices, created with For now, lets forget about, Blue Wallet and LNDHub for the sake of simplicity. Here is my setup:
Looking at the code I can see that LND rejects duplicated payments in some flows but not others, for example, looking at
With that said I have two questions that maybe you can answer:
|
Beta Was this translation helpful? Give feedback.
-
You are correct. First of all I had no idea about Lightning: Testnet Wallet. The app was using a really old version of the protocol, even before having tlvs, so it should be avoided. We have already removed it from the app store. No well-intentioned user should hit this because all the wallets are already updated and if someone hacks a tool to "exploit" it using the old format s/he is basically giving you money for free so it is not critical. We need to rewrite some of this logic (after 6288) so it gets easier to reason about but this is basically a bug (for an edge case but a bug). If you tried to paid them in the reversed order: first with the Testnet wallet and then with blue wallet you would see that your node refuses to take the payment.
Yes, it should notify you. This is something that shouldn't happen in production so it's low priority. I will create another issue to track it.
Yes, it has to be the sender the one that takes care of this because the sender cannot trust that the node s/he is paying to or any of the other nodes in the network will behave nicely. |
Beta Was this translation helpful? Give feedback.
-
Yes, I noticed that.
Thanks, if possible please share the issue, I would like to keep an eye on it. @positiveblue ok, I feel like I understand this flow a little bit better, once again thanks for the explanation. |
Beta Was this translation helpful? Give feedback.
-
Hi @positiveblue, I have a follow up question that maybe you can help with. Still regarding this flow, is there any way I can configure my LND node to always go through the My understanding is that only For example, I was taking a look at
For my use case, does it make sense if I set both of those flags to required instead of optional? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I did a couple of tests and as soon as I set I can see this in the wallet's logs:
In this example, 16 matches |
Beta Was this translation helpful? Give feedback.
I did a couple of tests and as soon as I set
PaymentAddrRequired
orMPPRequired
the old Lightning: Testnet Wallet rejects the invoice and doesn't even allow the payment to start.I can see this in the wallet's logs:
In this example, 16 matches
MPPRequired