Trying to call .transfer() within a function makes it fail. I am aware that the difference between .send() and .transfer() is that .send dont throw. The function works properly when using .send(), but fails when using .transfer. I simiplified the transfer-call to narrow down the fault-possibilities. Here is my code:
contract AuctionHouse is ItemOwnership {
constructor () public payable {}
function () external payable {}
function purchaseAuction(uint _id, address _buyer) external payable {
Auction memory auction = auctions[auctionIndexes[_id]];
require(
msg.sender == _buyer ||
approvedForAll[_buyer][msg.sender],
"You must have authority over purchasing account");
require(isOnAuction(_id), "That item is not on auction");
require(auction.startTime + auction.expiration > now, "auction is expired");
require(_buyer != ownerOfItem[_id], "Can't purchase your own item");
//remove item from auctionhouse and transfer ownership
removeAuction(_id, _buyer);
//This solution of transferring an auction prevents re-entrancy attacks by
//transferring the item and taking it off the auction house before transferring the currency.
//Converts from Wei to Finney
msg.sender.transfer(1); // <------------------------------
//send out event
emit AuctionPurchased(_id, auction.price, auction.seller, _buyer);
}
edit: Made an extra test just to see if it worked. The following test also fails:
function test() public payable {
msg.sender.transfer(500);
}
transfer
to fail, but they're all much less likely in a simple test like this.