Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Payment and Refund Stuck

5 messages, Sep 22 to 24, 2015. Started by Mats Jerratsch.

Mats Jerratsch (2), Rusty Russell, Pierre, Joseph Poon

Permalink First message in the Wayback Machine

Mats Jerratsch permalink original

So far my impression was that an attacker that only stops one payment is just a nuisance, as the system can self-correct. The payer and payee can set a timeout. If the payment has not arrived after the timeout the payee can issue a refund back to the payer. The refund will pay to the same secret hash as the initial payment, and it will pay an amount that is sufficient such that the payer will receive his initial payment completely back. (That is, he might end up paying more refund than actual payment)

When the payer does receive the refund in his channel, he can be sure that the payment got invalidated. The payee must not reveal the secret, and even if he does, the funds will just circle back again. (plus the payee will pay fees for both transactions as a disincentive) This concept has been around already, at least I read it somewhere. However, I recently thought about it and got a couple of unresolved issues:

(1) How do we resolve the complete chain to remove both, the refund and the payment completely? Do we just wait until they timeout? This does not seem very efficient and it would maximise the damage the attacker would do to the network - that is, he is locking up the payment amount for N1 nodes on the first route and N2 nodes on the refund route for the maximum amount of time. I thought about letting the nodes resolve this on their own, but this would need cooperation from the very node that isn't relaying the payment in the first place.

Lets assume A wants to pay E, and it chose the route

A->B->C->D->E.

However, C is uncooperative in that he does accept the payment in the channel he has with B, but he is not relaying it further to D. (for whatever reason) So we end up with A->B->C

Now the timeout hits and E is making the refund payment

E->D->F->B->A

with the same secret hash.

A and B can resolve this, both payments are the same amount (as described above), so the payments net-worth is zero for both parties. Now B has a binding payment towards C for X-a bitcoin, and he receives X+a bitcoin from F. (with some fees a)

Quoted text (1 line)
>From the point of view of B, this is just a normal payment from F

towards C with 2a in fees. And while B can drop the payment he gets from F (they can just update the channel and remove the payment if B agrees), he still has a binding agreement towards the payment to C. Without C agreeing to drop the payment as well, B isn't in the position to drop the payment towards F, keeping up the complete chain.

(2) How do we resolve the case, where the refund gets stuck as well? Let's assume the same case as above, but this time F is uncooperative too. We end up with two chains of payments, where both payees don't get the payment:

A->B->C E->D->F

where C and F are both uncooperative. From the point of view of A, he has made a final payment that he cannot revoke on his own. He further has made the payment due to some contract, to which he expects some kind of service/good. Waiting out one day till the lightning timeout might not be an option for A. The same is true other way round, where E has issued the refund and is awaiting a new payment. Both parties can not sufficiently prove to the other party they haven't received the payment, and even if they could, the initial payment could still route correctly after some delay while the refund doesn't.

Thinking about it, I guess E could give out multiple refunds via other routes, until one finally arrives at the payer. As he is obliged to not reveal the secret anyways, these are just for resolving the issue at hand. However, this would again maximise the damage, as all additional refunds would need to timeout. Furthermore, a malicious payer could just claim he never received any refund, locking up lots of funds of the payee with very few efforts...

Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch <matsjj at gmail.com> writes:

Quoted text (14 lines)
> So far my impression was that an attacker that only stops one payment
> is just a nuisance, as the system can self-correct. The payer and
> payee can set a timeout. If the payment has not arrived after the
> timeout the payee can issue a refund back to the payer. The refund
> will pay to the same secret hash as the initial payment, and it will
> pay an amount that is sufficient such that the payer will receive his
> initial payment completely back. (That is, he might end up paying more
> refund than actual payment)
>
> When the payer does receive the refund in his channel, he can be sure
> that the payment got invalidated. The payee must not reveal the
> secret, and even if he does, the funds will just circle back again.
> (plus the payee will pay fees for both transactions as a disincentive)
> This concept has been around already, at least I read it somewhere.

Yes, I think it was Joseph Poon who suggested it. I'm keeping it in reserve for the moment, in case this becomes common enough that we need to code up a solution.

Your criticisms are valid, AFAICT.

Cheers, Rusty.

Pierre in reply to Mats Jerratsch permalink original

Hi Mats,

I am not sure I understand what you meant, so forgive me if my answer is a bit off topic.

Let's consider A->B->C->D->E.

The way lightning works is that A does *not* pay B, instead it locks the corresponding funds in a contract that can end up two ways : 1) B provides a secret R which means E got the funds, and the contract is fulfilled. 2) a timeout occurs in which case the contract is voided. So there is no refund because the payment never actually took place.

But what you might have meant is that you are aware how this works, but you still want a way for A to cancel the contract before the timeout, in case A and E cooperate and C is unresponsive.

I would say this is a bit contradictory because when A signed the initial contract, it basically acknowledged the fact that it is willing to take the risk to have its funds locked for at most $timeout if things go bad, right ? This is the essence of lightning after all.

That been said, I see two ways for A to reduce the timeout : - either find a shorter path (maybe even A->E) - or convince B/C/D to use small timeouts, maybe just a few blocks between each node. That would reduce A's timeout to a few hours, and I don't see why that wouldn't work. This might be the real answer to your problem, but I am certainly missing something!

Now that I think of it, I actually don't know why the default timeout is 1 day on the original lightning presentation, that seems really high.

Cheers,

Pierre

Mats Jerratsch in reply to Pierre permalink original

Hey Pierre,

I was mainly talking about the case where one node in the chain does not relay the payment to the next node. So this is mainly about recovering, such that we can finish the payment without waiting for the timeout (which would piss off users so much). And this is possible in general. I feel I was either very unclear or you should reread my post again, as you just talk about timeouts (which is more of a layer-0 variable than a layer-1 mitigating technique).

I have discussed in https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2015/timeframes-for-refunds-and-revocation#m-b912d5b4 that the revocation time and timeout time must be identical. I'm still not sure if I am missing something, but it does seem logical. It is the one drawback we have from having all outputs directly to the parties, instead of spending them to another set of multisig addresses. Indeed, one day payment timeout is a lot, but one day revocation time is quite low, as it means all parties has to check the blockchain at least once a day, every day...

Cheers, Mats

2015-09-24 13:13 GMT+01:00 Pierre <pm+lists at acinq.fr>:

Quoted text (37 lines)
> Hi Mats,
>
> I am not sure I understand what you meant, so forgive me if my answer
> is a bit off topic.
>
> Let's consider A->B->C->D->E.
>
> The way lightning works is that A does *not* pay B, instead it locks
> the corresponding funds in a contract that can end up two ways :
> 1) B provides a secret R which means E got the funds, and the contract
> is fulfilled.
> 2) a timeout occurs in which case the contract is voided. So there is
> no refund because the payment never actually took place.
>
> But what you might have meant is that you are aware how this works,
> but you still want a way for A to cancel the contract before the
> timeout, in case A and E cooperate and C is unresponsive.
>
> I would say this is a bit contradictory because when A signed the
> initial contract, it basically acknowledged the fact that it is
> willing to take the risk to have its funds locked for at most $timeout
> if things go bad, right ? This is the essence of lightning after all.
>
> That been said, I see two ways for A to reduce the timeout :
> - either find a shorter path (maybe even A->E)
> - or convince B/C/D to use small timeouts, maybe just a few blocks
> between each node. That would reduce A's timeout to a few hours, and I
> don't see why that wouldn't work. This might be the real answer to
> your problem, but I am certainly missing something!
>
> Now that I think of it, I actually don't know why the default timeout
> is 1 day on the original lightning presentation, that seems really
> high.
>
> Cheers,
>
> Pierre
Joseph Poon in reply to Rusty Russell permalink original

Hi Mats,

Yes, I agree whole heartedly! See my related comment here: https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2015/payment-re-routing#m-361311e0

Two hashes are necessary for this type of invalidation.

On Thu, Sep 24, 2015 at 03:26:30PM +0930, Rusty Russell wrote:

Quoted text (19 lines)
> Mats Jerratsch <matsjj at gmail.com> writes:
> > So far my impression was that an attacker that only stops one payment
> > is just a nuisance, as the system can self-correct. The payer and
> > payee can set a timeout. If the payment has not arrived after the
> > timeout the payee can issue a refund back to the payer. The refund
> > will pay to the same secret hash as the initial payment, and it will
> > pay an amount that is sufficient such that the payer will receive his
> > initial payment completely back. (That is, he might end up paying more
> > refund than actual payment)
> >
> > When the payer does receive the refund in his channel, he can be sure
> > that the payment got invalidated. The payee must not reveal the
> > secret, and even if he does, the funds will just circle back again.
> > (plus the payee will pay fees for both transactions as a disincentive)
> > This concept has been around already, at least I read it somewhere.
>
> Yes, I think it was Joseph Poon who suggested it.  I'm keeping it in
> reserve for the moment, in case this becomes common enough that we need
> to code up a solution.

Yes, seems like something to tack on later.