Skip to content

Commit

Permalink
Merge pull request #1533 from ethersphere/frontier/etherbase
Browse files Browse the repository at this point in the history
Etherbase defaults to first account even if it is created during the session
  • Loading branch information
obscuren committed Jul 28, 2015
2 parents 1fad879 + 1356daa commit a281df7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/geth/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestAccounts(t *testing.T) {
defer os.RemoveAll(tmp)

checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`)
checkEvalJSON(t, repl, `eth.coinbase`, `null`)
checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`)
val, err := repl.re.Run(`personal.newAccount("password")`)
if err != nil {
t.Errorf("expected no error, got %v", err)
Expand All @@ -170,6 +170,7 @@ func TestAccounts(t *testing.T) {
}

checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`)

}

func TestBlockChain(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,11 @@ func (s *Ethereum) StartMining(threads int) error {
func (s *Ethereum) Etherbase() (eb common.Address, err error) {
eb = s.etherbase
if (eb == common.Address{}) {
err = fmt.Errorf("etherbase address must be explicitly specified")
addr, e := s.AccountManager().AddressByIndex(0)
if e != nil {
err = fmt.Errorf("etherbase address must be explicitly specified")
}
eb = common.HexToAddress(addr)
}
return
}
Expand Down

0 comments on commit a281df7

Please sign in to comment.