Sidechains

有人可以給我 ELI5 進行比特幣原子交換嗎?

  • June 5, 2017

我在這裡閱讀 wiki 頁面:https ://en.bitcoin.it/wiki/Atomic_cross-chain_trading

我了解使用者可以創建交易而無需對其進行簽名並且不會將其廣播到網路。我知道這是讓原子交換發揮作用的主要概念。但是我對每個步驟的確切工作方式有點困惑。有人可以解釋每一行嗎?

A picks a random number x

A creates TX1: "Pay w BTC to <B's public key> if (x for H(x) known and signed by B) or (signed by A & B)"

A creates TX2: "Pay w BTC from TX1 to <A's public key>, locked 48 hours in the future, signed by A"

A sends TX2 to B

B signs TX2 and returns to A

1) A submits TX1 to the network

B creates TX3: "Pay v alt-coins to <A-public-key> if (x for H(x) known and signed by A) or (signed by A & B)"

B creates TX4: "Pay v alt-coins from TX3 to <B's public key>, locked 24 hours in the future, signed by B"

B sends TX4 to A

A signs TX4 and sends back to B

2) B submits TX3 to the network

3) A spends TX3 giving x

4) B spends TX1 using x

This is atomic (with timeout).  If the process is halted, it can be reversed no matter when it is stopped.

Before 1: Nothing public has been broadcast, so nothing happens
Between 1 & 2: A can use refund transaction after 72 hours to get his money back
Between 2 & 3: B can get refund after 24 hours.  A has 24 more hours to get his refund
After 3: Transaction is completed by 2
- A must spend his new coin within 24 hours or B can claim the refund and keep his coins
- B must spend his new coin within 72 hours or A can claim the refund and keep his coins

For safety, both should complete the process with lots of time until the deadlines.

我認為如果你抽像一點,這更容易理解。在高層次上,原子交換非常簡單:雙方建立交易,以便他們都可以將他們的硬幣向某些(預先確定的)散列揭示原像H。最初,一方知道原像。他們必須展示它才能拿走他們的硬幣,所以拿走他們的硬幣的行為足以讓對方拿走他們的硬幣。

更具體地說,OP 中的 Tier Nolan 的工作方式如下。

  1. A隨機選擇一個x並給H(x)B。
  2. A 將她的硬幣發送到 2-of-2 的輸出端,如果 B 顯示 ,則 B 可以使用該輸出端x。類似地,B 將他的硬幣發送到 2-of-2 輸出,如果 A 透露 ,則 A 可以使用該輸出x。它們分別是 TX1 和 TX3。
  3. (在廣播這些之前,他們創建了鎖定時間的“退款”交易 TX2 和 TX4。重要的是,A 的鎖定時間比 B 的要長得多,這樣如果她得到退款,B 已經很長時間才能收到他的退款,並且不在A 透露x也拿走他的硬幣的風險。)
  4. 這時,A 拿走了她的硬幣,露出x
  5. 看到這一點,B 學習x並拿走了他的硬幣。

有一種稱為硬幣交換的變體,x它不會觸及區塊鏈,其中步驟 (4) 和 (5) 被替換為 A 揭示x鏈下,然後簽名者只是互相給予硬幣,僅用x作備份。這使鎖定時間結構複雜化,並且還需要保存不同形狀的交易x及其在區塊鏈上的散列,不幸的是,這使協議看起來非常可怕,但這就是正在發生的一切。

引用自:https://bitcoin.stackexchange.com/questions/54120