decred / atomicswap

On-chain atomic swaps for Decred and other cryptocurrencies.
https://blog.decred.org/2017/09/20/On-Chain-Atomic-Swaps/
ISC License
509 stars 231 forks source link

Why is auditcontract an offline Command? #88

Closed jmozah closed 6 years ago

jmozah commented 6 years ago

According to the readme, after party A "Initiates" the swap, Party B audits the contract and the contract transaction.

What i understand is.. Party A will pass on the entire contract and the contract transaction to party B. Party B checks the contract contents offline (i.e.) not consulting the block chain.

My question is : What if the party A gives a malicious contract and have a different one on the blockchain? How is this situation avoided?

jmozah commented 6 years ago

Lets say i run a full node and i want to audit the contents on the chain.

The "contract transaction" can be easily pulled from the chain using the gettransaction command. This gives the value only.

But for other fields like recipients address, we need the contract contents. Is there a way to get the "contract" contents from the chain?

jrick commented 6 years ago

The contract has not hit the blockchain at the point it is audited. The contract appears in the redeeming transactions, not the contract payment (which pays to a hash of the contract script).

jmozah commented 6 years ago

understood that it is not in the chain yet. So how can one be sure that the "contract transaction" passed by party A to party B is valid?

jrick commented 6 years ago

auditcontract is passed both the contract payment transaction and the contract itself, and the command verifies that the contract payment transaction pays to the contract script hash. It's the user's responsibility to ensure that the contract transaction is mined.

jmozah commented 6 years ago

ok. Party B has to make sure that the given "contract transaction" is mined, and then perform the audit.

jrick commented 6 years ago

Both parties need to audit the other's contract.

jrick commented 6 years ago

Closing due to age and I believe the question has been answered.