polyswarm / relay

Sidechain relay for PolySwarm, the first decentralized threat intelligence market.
https://polyswarm.io
GNU General Public License v3.0
2 stars 1 forks source link

Check that withdrawal will succeed before sending #96

Closed Rizato closed 4 years ago

Rizato commented 4 years ago

There are several requires values that must pass to post a withdrawal. If these fail, we don't even want to send the transaction since that is a waste of gas.

Checked in all withdrawals

require(destination != address(0), "Invalid destination address");
require((destination == feeWallet && amount > 0) || amount > fees, "Withdrawal amount is less than or equal to fees");
require(flushBlock == 0, "Contract is flushed, cannot withdraw");

Checked with looking at past, unapproved withdrawals

require(w.destination == destination, "Destination mismatch");
require(w.amount == net, "Amount mismatch");