From 1356daad276b849a192c84834d78a6cf32d739eb Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 27 Jul 2015 10:50:29 +0200 Subject: [PATCH] etherbase defaults to first account even if created during the session --- cmd/geth/js_test.go | 3 ++- eth/backend.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index aebf2d5526..67c36dfe71 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -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) @@ -170,6 +170,7 @@ func TestAccounts(t *testing.T) { } checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`) + } func TestBlockChain(t *testing.T) { diff --git a/eth/backend.go b/eth/backend.go index cba1b3939a..4b8c4858f1 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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 }