tornado-core/contracts/ETHTornado.sol

47 lines
1.8 KiB
Solidity
Raw Normal View History

2019-08-20 22:39:21 +02:00
// https://tornado.cash
/*
2021-02-11 07:23:18 +01:00
* d888888P dP a88888b. dP
* 88 88 d8' `88 88
* 88 .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b. 88 .d8888b. .d8888b. 88d888b.
* 88 88' `88 88' `88 88' `88 88' `88 88' `88 88' `88 88 88' `88 Y8ooooo. 88' `88
* 88 88. .88 88 88 88 88. .88 88. .88 88. .88 dP Y8. .88 88. .88 88 88 88
* dP `88888P' dP dP dP `88888P8 `88888P8 `88888P' 88 Y88888P' `88888P8 `88888P' dP dP
* ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
*/
2019-08-20 22:39:21 +02:00
2021-02-11 07:03:43 +01:00
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
2019-08-20 22:39:21 +02:00
2019-12-13 14:49:19 +01:00
import "./Tornado.sol";
2019-08-20 22:39:21 +02:00
2019-12-13 14:49:19 +01:00
contract ETHTornado is Tornado {
2019-08-20 22:39:21 +02:00
constructor(
2019-11-01 02:14:01 +01:00
IVerifier _verifier,
2021-02-11 08:00:53 +01:00
IHasher _hasher,
2019-10-04 16:27:47 +02:00
uint256 _denomination,
2021-02-11 06:37:18 +01:00
uint32 _merkleTreeHeight
2021-02-11 07:23:18 +01:00
) public Tornado(_verifier, _hasher, _denomination, _merkleTreeHeight) {}
2019-08-20 22:39:21 +02:00
2021-02-11 07:03:43 +01:00
function _processDeposit() internal override {
2019-11-04 20:45:56 +01:00
require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
}
2021-02-11 07:23:18 +01:00
function _processWithdraw(
address payable _recipient,
address payable _relayer,
uint256 _fee,
uint256 _refund
) internal override {
2019-10-17 17:54:21 +02:00
// sanity checks
2019-12-13 14:49:19 +01:00
require(msg.value == 0, "Message value is supposed to be zero for ETH instance");
require(_refund == 0, "Refund value is supposed to be zero for ETH instance");
2019-10-07 06:15:06 +02:00
2021-02-11 07:03:43 +01:00
(bool success, ) = _recipient.call{ value: denomination - _fee }("");
2019-11-08 12:41:39 +01:00
require(success, "payment to _recipient did not go thru");
2019-09-06 23:22:30 +02:00
if (_fee > 0) {
2021-02-11 07:03:43 +01:00
(success, ) = _relayer.call{ value: _fee }("");
2019-11-08 12:41:39 +01:00
require(success, "payment to _relayer did not go thru");
2019-08-20 22:39:21 +02:00
}
2019-09-06 23:22:30 +02:00
}
2019-08-20 22:39:21 +02:00
}