背景
运行OEC主网节点时,用户通过RPC请求调用personal_newAccount,生成OEC账户。用户期待通过该API创建账户的同时,输出keystore文件,与以太坊API保持一致。该帖子提供导出keystore方法。
问题
用户调用personal_newAccount接口,只生成info和address文件。
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["This is the passphrase"],"id":1}' -H "Content-Type: application/json" https://localhost:26659
解决方案
目前该功能仅支持keyring-backend为test的情况。
1.下载编译最新release版本代码
git clone -b latest_version https://github.com/okex/exchain.git # latest_version可以通过链接 https://github.com/okex/exchain/releases/latest 查看
cd exchain
make mainnet/testnet
2.在启动OEC节点的命令中,增加--export-keystore,并设置keyring-bakend为test,如:
exchaind start --rpc.unsafe \
...
--export-keystore \
--keyringbackend test \
...
- 每次调用personal_newAccount,将会导出新建账户的keystore文件在home目录的 keyring-test-exchain中。