<p>The process of saying that the payment failed and having to redo it means that the channel is first updated to a state where Alice hadn't sent the 1000 sats. The money is not gone. So if Bob were to do that, then he would be the one that is out 1000 sats because Charlie can claim the HTLC to him.</p>

CC BY-SA 4.0
2022-08-13T19:03:46.977Z
2022-08-13T19:03:46.977Z
Ava Chow
<p>I was reading about HTLC and how Charlie have to create a random number and generates its SHA256 hash that is supposed to be used by Bob in the end to finalize the payment he has received from Alice.</p>
<p>Here are the steps from <a href="https://en.bitcoin.it/wiki/Hash_Time_Locked_Contracts" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Hash_Time_Locked_Contracts</a></p>
<ol>
<li>Alice opens a payment channel to Bob, and Bob opens a payment channel to Charlie.</li>
<li>Alice wants to buy something from Charlie for 1,000 satoshis.</li>
<li>Charlie generates a random number and generates its SHA256 hash. Charlie gives that hash to Alice.</li>
<li>Alice uses her payment channel to Bob to pay him 1,000 satoshis, but she adds the hash Charlie gave her to the payment along with an extra condition: in order for Bob to claim the payment, he has to provide the data which was used to produce that hash.</li>
<li>Bob uses his payment channel to Charlie to pay Charlie 1,000 satoshis, and Bob adds a copy of the same condition that Alice put on the payment she gave Bob.</li>
<li>Charlie has the original data that was used to produce the hash (called a pre-image), so Charlie can use it to finalize his payment and fully receive the payment from Bob. By doing so, Charlie necessarily makes the pre-image available to Bob.</li>
<li>Bob uses the pre-image to finalize his payment from Alice</li>
</ol>
<p>But what would happen if Bob and Charlie decided to cheat and at the step 4 just after Alice send the 1000 sats Charlie give to Bob the secret number that was supposed to be used in step 7 share the sats between them and then Bob said that Alice payment was wrong and she have to do it again or something else.</p>
<p>I suppose this kind of attack would not be worth because</p>
<ol>
<li>you have to wait for Alice to pick a cheating peer Bob and Charlie.</li>
<li>the attack would not bring many benefit since lightning is not made
for big payment.</li>
<li>Bob and Charlie would become suspect and loose reputation in the
network.</li>
</ol>
<p>I was wondering if I was missing something here or this kind of attack can happen</p>

<security><lightning-network><hash><smartcontracts><hash-time-locked-contract>
What prevent users from cheating in an HTLC contract
Saxtheowl
# What prevent users from cheating in an HTLC contract

(Asked by: username_0 on 2022-08-13)

I was reading about HTLC and how Charlie have to create a random number and generates its SHA256 hash that is supposed to be used by Bob in the end to finalize the payment he has received from Alice.

Here are the steps from <https://en.bitcoin.it/wiki/Hash_Time_Locked_Contracts>

1. Alice opens a payment channel to Bob, and Bob opens a payment channel to Charlie.
2. Alice wants to buy something from Charlie for 1,000 satoshis.
3. Charlie generates a random number and generates its SHA256 hash. Charlie gives that hash to Alice.
4. Alice uses her payment channel to Bob to pay him 1,000 satoshis, but she adds the hash Charlie gave her to the payment along with an extra condition: in order for Bob to claim the payment, he has to provide the data which was used to produce that hash.
5. Bob uses his payment channel to Charlie to pay Charlie 1,000 satoshis, and Bob adds a copy of the same condition that Alice put on the payment she gave Bob.
6. Charlie has the original data that was used to produce the hash (called a pre-image), so Charlie can use it to finalize his payment and fully receive the payment from Bob. By doing so, Charlie necessarily makes the pre-image available to Bob.
7. Bob uses the pre-image to finalize his payment from Alice

But what would happen if Bob and Charlie decided to cheat and at the step 4 just after Alice send the 1000 sats Charlie give to Bob the secret number that was supposed to be used in step 7 share the sats between them and then Bob said that Alice payment was wrong and she have to do it again or something else.

I suppose this kind of attack would not be worth because

1. you have to wait for Alice to pick a cheating peer Bob and Charlie.
2. the attack would not bring many benefit since lightning is not made
   for big payment.
3. Bob and Charlie would become suspect and loose reputation in the
   network.

I was wondering if I was missing something here or this kind of attack can happen

**Tags:** security, lightning-network, hash, smartcontracts, hash-time-locked-contract


---

## 1 answers

### Answer by username_1 on 2022-08-13. Score: 1 | Accepted answer

The process of saying that the payment failed and having to redo it means that the channel is first updated to a state where Alice hadn't sent the 1000 sats. The money is not gone. So if Bob were to do that, then he would be the one that is out 1000 sats because Charlie can claim the HTLC to him.


---

