diff options
author | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
---|---|---|
committer | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
commit | 3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch) | |
tree | 401c52c4972a68229ea283a394a0b0a5f3cfdc8e /contracts | |
parent | a5330fe0c569b75cb8a524f60f7e8dc06498262b (diff) | |
parent | fe070ab5c32702033489f1b9d1655ea1b894c29e (diff) | |
download | dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2 dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip |
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'contracts')
-rw-r--r-- | contracts/chequebook/contract/chequebook.sol | 19 | ||||
-rw-r--r-- | contracts/release/contract.sol | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/contracts/chequebook/contract/chequebook.sol b/contracts/chequebook/contract/chequebook.sol index 845ba464b..8d6e85d11 100644 --- a/contracts/chequebook/contract/chequebook.sol +++ b/contracts/chequebook/contract/chequebook.sol @@ -1,7 +1,9 @@ -import "mortal"; +pragma solidity ^0.4.18; + +import "https://github.com/ethereum/solidity/std/mortal.sol"; /// @title Chequebook for Ethereum micropayments -/// @author Daniel A. Nagy <daniel@ethdev.com> +/// @author Daniel A. Nagy <daniel@ethereum.org> contract chequebook is mortal { // Cumulative paid amount in wei to each beneficiary mapping (address => uint256) public sent; @@ -21,26 +23,23 @@ contract chequebook is mortal { uint8 sig_v, bytes32 sig_r, bytes32 sig_s) { // Check if the cheque is old. // Only cheques that are more recent than the last cashed one are considered. - if(amount <= sent[beneficiary]) return; + require(amount > sent[beneficiary]); // Check the digital signature of the cheque. - bytes32 hash = sha3(address(this), beneficiary, amount); - if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return; + bytes32 hash = keccak256(address(this), beneficiary, amount); + require(owner == ecrecover(hash, sig_v, sig_r, sig_s)); // Attempt sending the difference between the cumulative amount on the cheque // and the cumulative amount on the last cashed cheque to beneficiary. uint256 diff = amount - sent[beneficiary]; if (diff <= this.balance) { // update the cumulative amount before sending sent[beneficiary] = amount; - if (!beneficiary.send(diff)) { - // Upon failure to execute send, revert everything - throw; - } + beneficiary.transfer(diff); } else { // Upon failure, punish owner for writing a bounced cheque. // owner.sendToDebtorsPrison(); Overdraft(owner); // Compensate beneficiary. - suicide(beneficiary); + selfdestruct(beneficiary); } } } diff --git a/contracts/release/contract.sol b/contracts/release/contract.sol index 554cf7290..b9d94c756 100644 --- a/contracts/release/contract.sol +++ b/contracts/release/contract.sol @@ -77,7 +77,7 @@ contract ReleaseOracle { } } - // signers is an accessor method to retrieve all te signers (public accessor + // signers is an accessor method to retrieve all the signers (public accessor // generates an indexed one, not a retrieve-all version). function signers() constant returns(address[]) { return voters; |