Build a two-way trading channel

in trading •  4 years ago 

Content

To build a two-way channel, in layman's terms, Bob and Alice each produce some btc, such as 5btc, and store it in a 2-2 multi-signature address controlled by both of them. However, Alice and Bob do not trust each other. Bob is afraid that after he transfers btc, Alice does not transfer btc and does not provide a private key to help Bob unlock the coins, making the funds fall into an endless loop. Then, we need to build a two-way transaction channel without mutual trust. The construction method is as follows:

Build a two-way trading channel

  1. Alice uses the public key A1 and Bob uses the public key B1 to generate two 2-2 multi-signature addresses: A1B1, B1A1

  2. Alice constructs a transaction and transfers it to B1A1 address 5btc. The transaction is not signed or broadcast.

  3. Alice constructs another transaction 1, the originating address is B1A1, and the destination address is Bitcoin address A1. If this transaction is broadcast, it needs to go through 1000 blocks before it can be packaged

  4. Alice sends transaction 1 to Bob separately, and asks Bob to sign the transaction. Bob discovers that this transaction is just that Alice transfers his coins back to him, which has no effect on Bob. Bob will sign and send transaction 1 back to Alice.

  5. Alice receives transaction 1 signed by Bob and uses A1 signature to test the transaction signed with the B1 public key. The test is successful

  6. At this time, Alice can safely broadcast the transaction of step 2. Even if Bob does not cooperate, Alice can get her coins back. After this step is completed, the B1A1 address receives the 5btc recharged by Alice

  7. Bob also uses the same operation to recharge 5btc to the B1A1 address, and keeps the transaction 2 signed by A1, so he can redeem his coins at any time

  8. Although the B1A1 address has received their respective money, Bob and Alice still have transaction 1 and transaction 2 on their hands, and there is a risk of breaking the contract at any time. Therefore, the last step requires Bob and Ailce to jointly initiate a transaction to transfer the 10btc in the B1A1 address to the A1B1 address, thus completing the construction of the two-way channel of the Lightning Network

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!