Просмотр исходного кода

doc/testnet/atomic-swap: simplyfied outputs visualization

skoupidi 1 год назад
Родитель
Сommit
4bbb88f8dd
2 измененных файлов с 60 добавлено и 46 удалено
  1. 60 46
      doc/src/testnet/atomic-swap.md
  2. 0 0
      doc/src/testnet/img/pablo2.jpg

+ 60 - 46
doc/src/testnet/atomic-swap.md

@@ -1,10 +1,11 @@
 # Atomic Swaps
 # Atomic Swaps
 
 
-In order to do an atomic swap with someone, you will first have to agree
-on what tokens you wish to swap. For example purposes, let's say you want
-to swap `40` `WCKD` (which is the balance you should have left over after
-doing the payment from the previous page) for your counterparty's `17.31`
-`MLDY`. For this tutorial the counterparty is yourself.
+In order to do an atomic swap with someone, you will first have to
+agree on what tokens you wish to swap. For example purposes, let's say
+you want to swap `40` `ANON` (which is the balance you should have left
+over after doing the payment from the previous page) for your
+counterparty's `20` `DAWN`. For this tutorial the counterparty is
+yourself.
 
 
 To protect your anonymity from the counterparty, the swap can only send
 To protect your anonymity from the counterparty, the swap can only send
 entire coins. To create a smaller coin denomination, send yourself the
 entire coins. To create a smaller coin denomination, send yourself the
@@ -12,103 +13,116 @@ amount you want to swap. Then check you have a spendable coin to swap
 with. Note that the coin overview might look very different depending
 with. Note that the coin overview might look very different depending
 on your activity:
 on your activity:
 
 
-```
+```shell
 $ ./drk wallet --coins
 $ ./drk wallet --coins
-```
 
 
-![coins](img/spent-coins.png)
+ Coin            | Spent | Token ID        | Aliases | Value                    | Spend Hook | User Data | Spent TX
+-----------------+-------+-----------------+---------+--------------------------+------------+-----------+-----------------
+ EGV6rS...pmmm6H | true  | 241vAN...KcLssb | DRK     | 2000000000 (20)          | -          | -         | fbbd7a...5f2b19
+...
+ H6Bc49...Zb6k8h | false | {TOKEN2}        | DAWN    | 2000000000 (20)          | -          | -         | -
+ 47QnyR...1T7igm | true  | {TOKEN1}        | ANON    | 4269000000 (42.69)       | -          | -         | 47b481...b07395
+ 5UUJbH...trdQHY | false | {TOKEN1}        | ANON    | 4000000000 (40)          | -          | -         | -
+ EEneNB...m6mxTC | false | 241vAN...KcLssb | DRK     | 1999442971 (19.97253683) | -          | -         | -
+```
 
 
 You'll have to initiate the swap and build your half of the swap tx:
 You'll have to initiate the swap and build your half of the swap tx:
 
 
+```shell
+$ ./drk otc init -v 40.0:20.0 -t ANON:DAWN > half_swap
 ```
 ```
-$ ./drk otc init -v 40.0:17.31 -t WCKD:MLDY > half_swap
-```
-
-![halfswap](img/halfswap.png)
 
 
 Then you can send this `half_swap` file to your counterparty and they
 Then you can send this `half_swap` file to your counterparty and they
-can create the other half by running:
+can create the other half and sign it by running:
 
 
-```
+```shell
 $ ./drk otc join < half_swap > full_swap
 $ ./drk otc join < half_swap > full_swap
 ```
 ```
 
 
-![fullswap](img/fullswap.png)
+They can now send it back to you. Finally, to make the swap transaction
+valid, you need to sign it as well
 
 
-They will sign the full_swap file and send it back to you. Finally,
-to make the swap transaction valid, you need to sign it as well
-
-```
+```shell
 $ ./drk otc sign < full_swap > signed_swap
 $ ./drk otc sign < full_swap > signed_swap
 ```
 ```
 
 
-![signedswap](img/signedswap.png)
-
 Now that the swap is signed, one of the parties (or a third one)
 Now that the swap is signed, one of the parties (or a third one)
 must attach the corresponding fee:
 must attach the corresponding fee:
 
 
-```
+```shell
 $ ./drk attach-fee < signed_swap > full_swap_with_fee
 $ ./drk attach-fee < signed_swap > full_swap_with_fee
 ```
 ```
 
 
-![signedswapwithfee](img/signedswapwithfee.png)
-
 Since a new call has been added to the transaction, both parties
 Since a new call has been added to the transaction, both parties
 must re-sign the full_swap_with_fee file, one by one.
 must re-sign the full_swap_with_fee file, one by one.
 
 
 Party A:
 Party A:
 
 
-```
+```shell
 $ ./drk otc sign < full_swap_with_fee > signed_full_swap_with_fee
 $ ./drk otc sign < full_swap_with_fee > signed_full_swap_with_fee
 ```
 ```
 
 
-![signedswapwithfee2](img/signedswapwithfee2.png)
-
 Party B:
 Party B:
 
 
+```shell
+$ ./drk otc sign < signed_full_swap_with_fee > swap.tx
 ```
 ```
-$ ./drk otc sign < signed_full_swap_with_fee > swap_tx
-```
-
-![swaptx](img/swap-tx.png)
 
 
 Now the complete swap transaction can be broadcasted:
 Now the complete swap transaction can be broadcasted:
 
 
-```
-$ ./drk broadcast < swap_tx
-```
+```shell
+$ ./drk broadcast < swap.tx
 
 
-![broadcast](img/broadcastswap.png)
+[mark_tx_spend] Processing transaction: d2a5e288e6ba44583ee12db9c7a0ed154c736d1aa841d70c7d3fa121c92dfc69
+[mark_tx_spend] Found Money contract in call 0
+[mark_tx_spend] Found Money contract in call 1
+Broadcasting transaction...
+Transaction ID: d2a5e288e6ba44583ee12db9c7a0ed154c736d1aa841d70c7d3fa121c92dfc69
+```
 
 
 On success, you should see a transaction ID. This transaction will now
 On success, you should see a transaction ID. This transaction will now
 also be in the mempool, so you should wait again until it's confirmed.
 also be in the mempool, so you should wait again until it's confirmed.
 
 
-![pablo-waiting2](pablo2.jpg)
+![pablo-waiting2](img/pablo2.jpg)
 
 
 After a while you should see the change in balances in your wallet:
 After a while you should see the change in balances in your wallet:
 
 
-```
+```shell
 $ ./drk wallet --balance
 $ ./drk wallet --balance
-```
 
 
-![balances](img/all-balances.png)
+ Token ID                                     | Aliases | Balance
+----------------------------------------------+---------+-------------
+ 241vANigf1Cy3ytjM1KHXiVECxgxdK4yApddL8KcLssb | DRK     | 19.96835727
+ {TOKEN1}                                     | ANON    | 40
+ {TOKEN2}                                     | DAWN    | 20
+```
 
 
 Since in this example we did an atomic swap with ourself, the balances are
 Since in this example we did an atomic swap with ourself, the balances are
 unchanged. We can confirm it actually happened successfully by checking
 unchanged. We can confirm it actually happened successfully by checking
 our coins:
 our coins:
 
 
-```
+```shell
 $ ./drk wallet --coins
 $ ./drk wallet --coins
-```
 
 
-![coins](img/swapcoins.png)
+ Coin            | Spent | Token ID        | Aliases | Value                    | Spend Hook | User Data | Spent TX
+-----------------+-------+-----------------+---------+--------------------------+------------+-----------+-----------------
+ EGV6rS...pmmm6H | true  | 241vAN...KcLssb | DRK     | 2000000000 (20)          | -          | -         | fbbd7a...5f2b19
+...
+ EEneNB...m6mxTC | true  | 241vAN...KcLssb | DRK     | 1999442971 (19.97253683) | -          | -         | d2a5e2...2dfc69
+ H6Bc49...Zb6k8h | true  | {TOKEN2}        | DAWN    | 2000000000 (20)          | -          | -         | d2a5e2...2dfc69
+ 5UUJbH...trdQHY | true  | {TOKEN1}        | ANON    | 4000000000 (40)          | -          | -         | d2a5e2...2dfc69
+ 4zwzZf...uMbVir | false | {TOKEN2}        | DAWN    | 2000000000 (20)          | -          | -         | -
+ BrqQuk...FcwW6d | false | {TOKEN1}        | ANON    | 4000000000 (40)          | -          | -         | -
+ EEneNB...m6mxTC | false | 241vAN...KcLssb | DRK     | 1999442971 (19.96834924) | -          | -         | -
+```
 
 
 Here you can see there are two entries for the tokens we used in the
 Here you can see there are two entries for the tokens we used in the
-swap: 17.31 MLDY and 40.00 WCKD. The first entry shows the `Spent` flag
+swap: 20.00 DAWN and 40.00 ANON. The first entry shows the `Spent` flag
 as `true` and the second entry shows the `Spent` flag as `false`. This
 as `true` and the second entry shows the `Spent` flag as `false`. This
-means the transaction was successful. Since we are swapping with ourself,
-we successfully spent the coins in the first half of the transaction,
-and re-minted to ourselves them in the second half of the transaction.
+means the transaction was successful. Since we are swapping with
+ourself, we successfully spent the coins in the first half of the
+transaction, and re-minted to ourselves them in the second half of the
+transaction.
 
 
 If you're testing atomic swaps with a counterparty and you can see
 If you're testing atomic swaps with a counterparty and you can see
 their tokens, that means the swap was successful.  In case you still
 their tokens, that means the swap was successful.  In case you still

+ 0 - 0
doc/src/testnet/pablo2.jpg → doc/src/testnet/img/pablo2.jpg