区块链研究实验室 | 闪电网络编码教程-花费HTLC执行可撤销交付

本文的目标是将HTLC用于可撤销交付,这与白皮书的图12相对应。

ffb718bf24ed4afa86a3a50bac5f2c0d

将HTLC用于可撤销交付的14个步骤:

由于内容是重复的,因此忽略前面的步骤,直接从第五步开始。如果您想了解前4个步骤,请参阅上一篇文章。

用于构建C1A和C1B(无符号)的多签名资金构建RD1a和RD1bC1A以及C1B交换签名以构建C2A和C2B(无符号)以构建RD2A和RD2B以构建HTD1B以构建HE1B以构建HELD1BC2A和C2B交换签名构建BR1a和BR1b需要花费C2B HE1B成本HED1B

建立C2a和C2b(无标志)

首先,Alice创建原始图像R并且还创建相应的散列H.只有当Bob知道原始图像R时,Alice才想要支付Bob 0.1 BTC。对于Bob,当Alice提供H时,他应该回答R以接收0.1 BTC。此时,Alice将私钥用作R,将公钥用作H.

160882718f0e4d11aa05d49f68de55dd

396869db8d484cf4b5f44ba6a71e121c

以同样的方式,Bob构建了C2b。

构建RD2a和RD2b

请参阅“构建RD1a和RD1b”部分中的上一篇文章。

构建HTD1b

如果Bob无法回答R,则只有Alice可以在3次确认时间锁定后广播该交易以退还0.1 BTC。对于Bob,最好在时间锁定到期之前回答R.

716d600618d6422bae8b657a9a564b50

The JSON format scriptSig is as follows:

68f04e8a2c0a4811ac09d3f60beb0a90

Please note that HT1a is a bit different from HTD1b, please refer

Build HE1b

Bob can broadcast this transaction at any time as long as he knows R. Unfortunately, he did not receive 0.1 BTC from the transaction.

a2f4c7cf2e5d4befbeeaf66f17246ae6

The JSON format scriptSig is as follows:

a6caf93d625048488c7bdb693b80d68a

Please note that HED1a is slightly different from HE1b, please refer to:

Build HERD1b

Bob can only broadcast this transaction after 10 confirmation time locks. Finally, Bob received 0.1 BTC from this transaction.

e8d1fc100f854532844982d410bb8dcf

Please note that building HTR1a is slightly different from H1b, please refer

Exchange signature of C2a and C2b

Alice lets Bob sign C2A. Now, Alice can broadcast this transaction at any time.

5f6816ca8260462e8d2dcdc990d40db2

In the same way, Bob asked Alice to sign C2b.

Build BR1a and BR1b

xx

跳过重复说明。请参阅“Build BR1a和BR1b”部分中的上一篇文章。

花C2b

鲍勃花了c2b。即使他知道R,他也无法立即收到Alice的0.1btc,因为herd1b上的时间被锁定了。

但是,如果Alice花费c2a,Bob一旦知道了R.就可以收到它。

fe25d75bc1af49baaa530d53b7ae9965

花费HTD1b

鲍勃接受了这笔交易来回答R.

7d19834adfab4a9c9e6f262343d6d459

花HERD1b

在10次锁定之后,Bob花了这笔交易来获得0.1 BTC。

b9ab5b0e60fb4c5e8644030437ea6457

好的,本章到此为止,我们将在下一节继续解释;