Decred is a new type of cryptographic currency to be centralized. At the end of 2017, Decred's developers released the ATOMICSWAP Toolkit, which supported the trans-chain atomic swaps of decred with Bitcoin, Litecoin, Monacoin, and other cryptographic currencies. Its main features are:
To be centralized without the need for third party hosting
To trust the trade.
Point to point trading, anti-censorship
Atomic transfer of assets
The use of Atomicswap block chains requires support for the following conditions: Transaction script Branch Trading scripts use the same hash algorithm transaction script signature Check transaction script support checklocktimeverify or checksequenceverify opcode
At present, most of the encrypted currencies from Bitcoin Fork are satisfied with the above conditions.
The implementation principle, mainly uses the transaction script function to realize the contract transaction. In the contract transaction, the Exchange amount, the recipient address, the Exchange password hash, the return address, the contract lockout time and other information are agreed. The design of the Exchange cipher is used to guarantee the atomic exchange and the contract lock design is mainly used to guarantee the normal return of funds in default situation.
Normally, an exchange process requires both sides to perform multiple steps, while both parties need interactive information in the execution process. The atomic interchange process mainly uses the following commands:
Initiate
For the first party to initialize the output contract transactions, Exchange passwords, Exchange password hashes, and a locked 48-hour fallback transaction and other information.
Participate
For the second party to initialize the output of a contract transaction similar to initiate, the difference is that the secret hash parameter must be consistent with the exchange password generated by the first party through the initiate command, and that the fallback transaction is locked for 24 hours.
Auditcontract
Review contract transaction content. It mainly looks at the output receiving address, Exchange amount, Exchange password hash, and rollback transaction lockout time in the contract transaction.
Redeem
Used by the party to exchange money from the contract for payment by the other party. The secret parameter must match the Exchange password in initiate. Once the first party publishes redeem to perform the redemption, the second party can execute the Extractsecret order to extract the Exchange password from the transaction, and then redeem its own target currency by executing the redeem.
Refund
Used to create and send a fallback transaction, which returns the currency in the contract transaction to the original sender.
Extractsecret
For the second party to withdraw the exchange password from the redeem transaction of the first party, and to redeem the target currency from the contract transaction of the first participant by exchanging the password.
A normal process of atomic exchange interaction:
Https://github.com/toxotguo/thinking/blob/master/Decred%20atomicswap%20%E8%B7%A8%E9%93%BE%E5%8E%9F%E5%AD%90%E8 %b5%84%e4%ba%a7%e8%bd%ac%e7%a7%bb%e5%b7%a5%e5%85%b7%e5%8c%85.md