improve PullPaymentCapable
This commit is contained in:
@ -13,11 +13,16 @@ contract PullPayment {
|
||||
}
|
||||
|
||||
// withdraw accumulated balance, called by payee
|
||||
function withdrawPayments() external {
|
||||
uint payment = payments[msg.sender];
|
||||
payments[msg.sender] = 0;
|
||||
if (!msg.sender.send(payment)) {
|
||||
payments[msg.sender] = payment;
|
||||
function withdrawPayments() {
|
||||
address payee = msg.sender;
|
||||
uint payment = payments[payee];
|
||||
|
||||
if (payment == 0) throw;
|
||||
if (this.balance < payment) throw;
|
||||
|
||||
payments[payee] = 0;
|
||||
if (!payee.send(payment)) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
import '../PullPayment.sol';
|
||||
|
||||
// Example class using PullPayment
|
||||
contract PullPaymentExample is PullPayment {
|
||||
// test helper function to call asyncSend
|
||||
function callSend(address dest, uint amount) external {
|
||||
asyncSend(dest, amount);
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,8 @@ import '../PullPayment.sol';
|
||||
// mock class using PullPayment
|
||||
contract PullPaymentMock is PullPayment {
|
||||
// test helper function to call asyncSend
|
||||
function callSend(address dest, uint amount) external {
|
||||
function callSend(address dest, uint amount) {
|
||||
asyncSend(dest, amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user