improve PullPaymentCapable

This commit is contained in:
Manuel Araoz
2016-10-11 19:26:48 -03:00
parent 5ec4fbeb45
commit 25a0210118
4 changed files with 89 additions and 21 deletions

View File

@ -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;
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}