This commit is contained in:
Daniel A. Nagy 2016-11-27 14:13:06 +00:00 committed by GitHub
commit 584fbfd4bd

View file

@ -28,9 +28,11 @@ contract chequebook is mortal {
// 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) { if (amount - sent[beneficiary] >= this.balance) {
if (beneficiary.send(amount - sent[beneficiary])) { // update the cumulative amount before sending
// Upon success, update the cumulative amount. sent[beneficiary] = amount;
sent[beneficiary] = amount; if (!beneficiary.send(amount - sent[beneficiary])) {
// Upon failure to execute send, revert everything
throw;
} }
} else { } else {
// Upon failure, punish owner for writing a bounced cheque. // Upon failure, punish owner for writing a bounced cheque.