aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/chequebook/contract/chequebook.sol
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/chequebook/contract/chequebook.sol')
-rw-r--r--contracts/chequebook/contract/chequebook.sol8
1 files changed, 5 insertions, 3 deletions
diff --git a/contracts/chequebook/contract/chequebook.sol b/contracts/chequebook/contract/chequebook.sol
index cb19d0b27..eefe6c063 100644
--- a/contracts/chequebook/contract/chequebook.sol
+++ b/contracts/chequebook/contract/chequebook.sol
@@ -28,9 +28,11 @@ contract chequebook is mortal {
// 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) {
- if (beneficiary.send(amount - sent[beneficiary])) {
- // Upon success, update the cumulative amount.
- sent[beneficiary] = amount;
+ // update the cumulative amount before sending
+ sent[beneficiary] = amount;
+ if (!beneficiary.send(amount - sent[beneficiary])) {
+ // Upon failure to execute send, revert everything
+ throw;
}
} else {
// Upon failure, punish owner for writing a bounced cheque.