mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Merge ee24dffae2 into 4936bec6c9
This commit is contained in:
commit
6978df47ef
1 changed files with 6 additions and 4 deletions
|
|
@ -27,10 +27,12 @@ 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) {
|
if (amount - sent[beneficiary] <= this.balance) {
|
||||||
if (beneficiary.send(amount - sent[beneficiary])) {
|
// Update the cumulative amount upfront to prevent re-entrancy.
|
||||||
// Upon success, update the cumulative amount.
|
|
||||||
sent[beneficiary] = amount;
|
sent[beneficiary] = amount;
|
||||||
|
if (!beneficiary.send(amount - sent[beneficiary])) {
|
||||||
|
// Upon failure, rollback.
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Upon failure, punish owner for writing a bounced cheque.
|
// Upon failure, punish owner for writing a bounced cheque.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue