local-rpc-account
Conflux-rust 提供了 RPC 用于外部跟 fullnode 交互,除了对外的 RPC 外,还有部分用于测试或本地开发. 比如本地 account 管理的接口:
- list
- new
- lock
- unlock
API
list
- method: accounts
- params:
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw ' {
"jsonrpc": "2.0",
"id": "15922956697249514502",
"method": "accounts",
"params": []
}'
new
- method: new_account
- password: password
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw ' {
"jsonrpc": "2.0",
"id": "15922956697249514502",
"method": "new_account",
"params": ["your-password"]
}'
lock
- method: lock_account
- params: address
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw ' {
"jsonrpc": "2.0",
"id": "15922956697249514502",
"method": "lock_account",
"params": ["address"]
}'
unlock
- method: unlock_account
- params: address, password, duration(可选,默认300s,传0永久解锁)
curl --location --request POST 'http://localhost:12537' \
--header 'Content-Type: application/json' \
--data-raw ' {
"jsonrpc": "2.0",
"id": "15922956697249514502",
"method": "unlock_account",
"params": ["address", "password", 3000]
}'
注意
调用以上接口列出和创建的account,均位于node所在的机器,所有账号以keystore 的形式保存与文件系统上, 具体存放目录参看这里