aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/address.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethchain/address.go')
-rw-r--r--ethchain/address.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/ethchain/address.go b/ethchain/address.go
index f1f27a1a5..9c6acbe08 100644
--- a/ethchain/address.go
+++ b/ethchain/address.go
@@ -6,19 +6,20 @@ import (
)
type Account struct {
- Amount *big.Int
- Nonce uint64
+ Address []byte
+ Amount *big.Int
+ Nonce uint64
}
-func NewAccount(amount *big.Int) *Account {
- return &Account{Amount: amount, Nonce: 0}
+func NewAccount(address []byte, amount *big.Int) *Account {
+ return &Account{address, amount, 0}
}
-func NewAccountFromData(data []byte) *Account {
- address := &Account{}
- address.RlpDecode(data)
+func NewAccountFromData(address, data []byte) *Account {
+ account := &Account{Address: address}
+ account.RlpDecode(data)
- return address
+ return account
}
func (a *Account) AddFee(fee *big.Int) {
@@ -29,6 +30,13 @@ func (a *Account) AddFunds(funds *big.Int) {
a.Amount.Add(a.Amount, funds)
}
+// Implements Callee
+func (a *Account) ReturnGas(value *big.Int, state *State) {
+ // Return the value back to the sender
+ a.AddFunds(value)
+ state.UpdateAccount(a.Address, a)
+}
+
func (a *Account) RlpEncode() []byte {
return ethutil.Encode([]interface{}{a.Amount, a.Nonce})
}