Content
HTLC was originally designed to serve the payment scenario of the same currency (that is, BTC), but later the Lightning Network announced that they relied on HTLC to create an off-chain cross-chain atomic swap (the swap between Bitcoin and Litecoin) Demo. It is still the example of Alice and Bob. Alice wants to exchange her 1BTC for Bob's 100LTC. At this time, HTLC can no longer be used to form a directed chain, but to create a ring. details as follows:
Preparation Phase:
Alice generates a random password s and provides its hash value to Bob
Alice and Bob establish a Bitcoin payment channel (which can include only these two people, or include more intermediaries), and agree on an HTLC: As long as Bob provides a password to pass the hash test, he can take away Alice's 1BTC, more than 2 hours , 1BTC back to Alice
Bob and Alice establish a Litecoin payment channel and agree on another HTLC: As long as Alice passes the hash test, he can take away Bob’s 100LTC and return it to Bob when it exceeds 1 hour.
Claim phase:
Alice provides her own generated password s and gets Bob's 100LTC.
The broadcasted password s is also used to ensure that Bob gets Alice's 1BTC.
It is the same as the example mentioned at the beginning.