diff --git a/console/console.go b/console/console.go index 7b9ed27e15..fde673be8b 100644 --- a/console/console.go +++ b/console/console.go @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/internal/jsre" "github.com/ethereum/go-ethereum/internal/jsre/deps" "github.com/ethereum/go-ethereum/internal/web3ext" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" "github.com/mattn/go-colorable" "github.com/peterh/liner" @@ -198,13 +199,22 @@ func (c *Console) initWeb3(bridge *bridge) error { return err } +var defaultAPIs = map[string]string{"eth": "1.0", "net": "1.0", "debug": "1.0"} + // initExtensions loads and registers web3.js extensions. func (c *Console) initExtensions() error { - // Compute aliases from server-provided modules. + const methodNotFound = -32601 apis, err := c.client.SupportedModules() if err != nil { - return fmt.Errorf("api modules: %v", err) + if rpcErr, ok := err.(rpc.Error); ok && rpcErr.ErrorCode() == methodNotFound { + log.Warn("Server does not support method rpc_modules, using default API list.") + apis = defaultAPIs + } else { + return err + } } + + // Compute aliases from server-provided modules. aliases := map[string]struct{}{"eth": {}, "personal": {}} for api := range apis { if api == "web3" {