Fix balance checking and email address

This commit is contained in:
Daniel A. Nagy 2017-09-08 07:50:10 +02:00 committed by GitHub
parent f2c5af1826
commit ed94916cf1

View file

@ -3,7 +3,7 @@ pragma solidity ^0.4.3;
import "mortal.sol" as mortal; import "mortal.sol" as mortal;
/// @title Chequebook for Ethereum micropayments /// @title Chequebook for Ethereum micropayments
/// @author Daniel A. Nagy <daniel@ethdev.com> /// @author Daniel A. Nagy <daniel@ethereum.org>
contract chequebook is mortal { contract chequebook is mortal {
// Cumulative paid amount in wei to each beneficiary // Cumulative paid amount in wei to each beneficiary
mapping (address => uint256) public sent; mapping (address => uint256) public sent;
@ -37,10 +37,11 @@ contract chequebook is mortal {
if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return; if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return;
// Attempt sending the difference between the cumulative amount on the cheque // Attempt sending the difference between the cumulative amount on the cheque
// and the cumulative amount on the last cashed cheque to beneficiary. // and the cumulative amount on the last cashed cheque to beneficiary.
if (amount - sent[beneficiary] >= this.balance) { diff = amount - sent[beneficiary];
if (diff <= this.balance) {
// update the cumulative amount before sending // update the cumulative amount before sending
sent[beneficiary] = amount; sent[beneficiary] = amount;
if (!beneficiary.send(amount - sent[beneficiary])) { if (!beneficiary.send(diff)) {
// Upon failure to execute send, revert everything // Upon failure to execute send, revert everything
throw; throw;
} }