Skip to content

Commit d7211de

Browse files
zeligobscuren
authored andcommitted
etherbase defaults to first account even if created during the session
1 parent cea2c0e commit d7211de

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/geth/js_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func TestAccounts(t *testing.T) {
159159
defer os.RemoveAll(tmp)
160160

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

172172
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`)
173+
173174
}
174175

175176
func TestBlockChain(t *testing.T) {

eth/backend.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,11 @@ func (s *Ethereum) StartMining(threads int) error {
488488
func (s *Ethereum) Etherbase() (eb common.Address, err error) {
489489
eb = s.etherbase
490490
if (eb == common.Address{}) {
491-
err = fmt.Errorf("etherbase address must be explicitly specified")
491+
addr, e := s.AccountManager().AddressByIndex(0)
492+
if e != nil {
493+
err = fmt.Errorf("etherbase address must be explicitly specified")
494+
}
495+
eb = common.HexToAddress(addr)
492496
}
493497
return
494498
}

0 commit comments

Comments
 (0)