forked from ethpm/ethpm-spec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWallet.sol
39 lines (30 loc) · 1.35 KB
/
Wallet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
pragma solidity ^0.4.0;
import {SafeMathLib} from "safe-math-lib/contracts/SafeMathLib.sol";
import {owned} from "owned/contracts/owned.sol";
/// @title Contract for holding funds in escrow between two semi trusted parties.
/// @author Piper Merriam <[email protected]>
contract Wallet is owned {
using SafeMathLib for uint;
mapping (address => uint) allowances;
/// @dev Fallback function for depositing funds
function() {
}
/// @dev Sends the recipient the specified amount
/// @notice This will send the reciepient the specified amount.
function send(address recipient, uint value) public onlyowner returns (bool) {
return recipient.send(value);
}
/// @dev Sets recipient to be approved to withdraw the specified amount
/// @notice This will set the recipient to be approved to withdraw the specified amount.
function approve(address recipient, uint value) public onlyowner returns (bool) {
allowances[recipient] = value;
return true;
}
/// @dev Lets caller withdraw up to their approved amount
/// @notice This will withdraw provided value, deducting it from your total allowance.
function withdraw(uint value) public returns (bool) {
allowances[msg.sender] = allowances[msg.sender].safeSub(value);
if (!msg.sender.send(value)) throw;
return true;
}
}