Created
June 14, 2021 07:57
-
-
Save johnson86tw/d3e267de20ddeabfe84aa8c5c3077efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) external payable nonReentrant { | |
require(_fee <= denomination, "Fee exceeds transfer value"); | |
require(!nullifierHashes[_nullifierHash], "The note has been already spent"); | |
require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one | |
require(verifier.verifyProof(_proof, [uint256(_root), uint256(_nullifierHash), uint256(_recipient), uint256(_relayer), _fee, _refund]), "Invalid withdraw proof"); | |
nullifierHashes[_nullifierHash] = true; | |
_processWithdraw(_recipient, _relayer, _fee, _refund); | |
emit Withdrawal(_recipient, _nullifierHash, _relayer, _fee); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment