ethermint icon indicating copy to clipboard operation
ethermint copied to clipboard

personal_newAccount failed in "file" keyring-backend mode

Open lcmmhcc opened this issue 2 years ago • 0 comments

System info: [Include Ethermint commit, operating system name, and other relevant details] latest main branch Steps to reproduce:

  1. [First Step] edit init.sh and set KEYRING="file" , instead of "test" sh init.sh
  2. [Second Step] call personal_newAccount json-rpc api.
  3. [and so on...]

Expected behavior: [What you expected to happen]

the same behavior as https://docs.evmos.org/developers/json-rpc/endpoints.html#personal-newaccount described

Actual behavior: [What actually happened]

first time , no response and tcp disconnected again, stuck in sending request

Additional info: [Include gist of relevant config, logs, etc.]

the similiar problem in personal_xxx json-rpc apis. like personal_importRawKey but it's ok in cli command like "ethermintd account add xxx" i suppose it's caused by the keyring passphrase .it seems theres no way to input keyring passphrase from JSON-RPC but the os.stdin.

see codes below

func newFileBackendKeyringConfig(name, dir string, buf io.Reader) keyring.Config {
	fileDir := filepath.Join(dir, keyringFileDirName)

	return keyring.Config{
		AllowedBackends:  []keyring.BackendType{keyring.FileBackend},
		ServiceName:      name,
		FileDir:          fileDir,
		FilePasswordFunc: newRealPrompt(fileDir, buf),
	}
func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
...
			pass, err := input.GetPassword("Enter keyring passphrase:", buf)
...
}

input.GetPassword in function newRealPrompt(fileDir, buf) will fail as called from RPC.

lcmmhcc avatar May 20 '22 08:05 lcmmhcc