Update PhoneToAddress.sol

This commit is contained in:
Igor Barinov 2016-05-18 17:20:03 -07:00
parent 243ee3ecaa
commit 25592ca9ea
1 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,5 @@
contract PhoneToAddress {
address owner;
bytes dataEmpty;
struct PhonePayment {
uint phone;
@ -7,6 +8,9 @@ contract PhoneToAddress {
}
mapping(address => PhonePayment) addresses;
mapping(uint => address) public phones;
function PhoneToAddress() {
owner = msg.sender;
}
function () {
addresses[msg.sender] = PhonePayment({phone: 0, payment: msg.value/100000000000000000, data: msg.data});
}
@ -14,6 +18,9 @@ contract PhoneToAddress {
addresses[addr] = PhonePayment({phone: phone, payment: 0, data: dataEmpty});
phones[phone] = addr;
}
function sendEtherToOwner() {
owner.send(this.balance);
}
function getPhoneByAddress(address addr) constant returns(uint) {
return addresses[addr].phone;
}
@ -30,4 +37,4 @@ contract PhoneToAddress {
return false;
}
}
}
}