From ed94916cf1973d63d29a50e972e0fcde15a3b9de Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Fri, 8 Sep 2017 07:50:10 +0200 Subject: [PATCH] Fix balance checking and email address --- swarm/services/chequebook/contract/chequebook.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swarm/services/chequebook/contract/chequebook.sol b/swarm/services/chequebook/contract/chequebook.sol index e6979c0f0b..36a56f2263 100644 --- a/swarm/services/chequebook/contract/chequebook.sol +++ b/swarm/services/chequebook/contract/chequebook.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.3; import "mortal.sol" as mortal; /// @title Chequebook for Ethereum micropayments -/// @author Daniel A. Nagy +/// @author Daniel A. Nagy contract chequebook is mortal { // Cumulative paid amount in wei to each beneficiary mapping (address => uint256) public sent; @@ -37,10 +37,11 @@ contract chequebook is mortal { if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return; // Attempt sending the difference between the cumulative amount on the cheque // 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 sent[beneficiary] = amount; - if (!beneficiary.send(amount - sent[beneficiary])) { + if (!beneficiary.send(diff)) { // Upon failure to execute send, revert everything throw; }