Keystore API
Because the node operator has access to your plain-text password, you should only create a keystore user on a node that you operate. If that node is breached, you could lose all your tokens. Keystore APIs are not recommended for use on Mainnet.
Every node has a built-in keystore. Clients create users on the keystore, which act as identities to be used when interacting with blockchains. A keystore exists at the node level, so if you create a user on a node it exists only on that node. However, users may be imported and exported using this API.
For validation and cross-chain transfer on the Mainnet, you should issue transactions through DijetsJS. That way control keys for your funds won't be stored on the node, which significantly lowers the risk should a computer running a node be compromised. See following docs for details:
This API set is for a specific node, it is unavailable on the public server.
Format#
This API uses the json 2.0
API format. For more information on making JSON RPC calls, see
here.
Endpoint#
_10/ext/keystore
Methods#
keystore.createUser#
Create a new user on dijets node with the specified username and password.
Signature:
_10keystore.createUser(_10 {_10 username:string,_10 password:string_10 }_10) -> {}
username
andpassword
can be at most 1024 characters.- Your request will be rejected if
password
is too weak.password
should be at least 8 characters and contain upper and lower case letters as well as numbers and symbols.
Example Call:
_10curl -X POST --data '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"keystore.createUser",_10 "params" :{_10 "username":"myUsername",_10 "password":"myPassword"_10 }_10}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
Example Response:
_10{_10 "jsonrpc": "2.0",_10 "id": 1,_10 "result": {}_10}
keystore.deleteUser#
Delete a user.
Signature:
_10keystore.deleteUser({username: string, password:string}) -> {}
Example Call:
_10curl -X POST --data '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"keystore.deleteUser",_10 "params" : {_10 "username":"myUsername",_10 "password":"myPassword"_10 }_10}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
Example Response:
_10{_10 "jsonrpc": "2.0",_10 "id": 1,_10 "result": {}_10}
keystore.exportUser#
Export a user. The user can be imported to another node with
keystore.importUser
. The user’s password remains encrypted.
Signature:
_10keystore.exportUser(_10 {_10 username:string,_10 password:string,_10 encoding:string //optional_10 }_10) -> {_10 user:string,_10 encoding:string_10}
encoding
specifies the format of the string encoding user data. Can only be hex
when a value is
provided.
Example Call:
_10curl -X POST --data '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"keystore.exportUser",_10 "params" :{_10 "username":"myUsername",_10 "password":"myPassword"_10 }_10}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
Example Response:
_10{_10 "jsonrpc": "2.0",_10 "id": 1,_10 "result": {_10 "user": "7655a29df6fc2747b0874e1148b423b954a25fcdb1f170d0ec8eb196430f7001942ce55b02a83b1faf50a674b1e55bfc00000000",_10 "encoding": "hex"_10 }_10}
keystore.importUser#
Import a user. password
must match the user’s password. username
doesn’t have to match the
username user
had when it was exported.
Signature:
_10keystore.importUser(_10 {_10 username:string,_10 password:string,_10 user:string,_10 encoding:string //optional_10 }_10) -> {}
encoding
specifies the format of the string encoding user data. Can only be hex
when a value is
provided.
Example Call:
_10curl -X POST --data '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"keystore.importUser",_10 "params" :{_10 "username":"myUsername",_10 "password":"myPassword",_10 "user" :"0x7655a29df6fc2747b0874e1148b423b954a25fcdb1f170d0ec8eb196430f7001942ce55b02a83b1faf50a674b1e55bfc000000008cf2d869"_10 }_10}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
Example Response:
_10{_10 "jsonrpc": "2.0",_10 "id": 1,_10 "result": {}_10}
keystore.listUsers#
List the users in this keystore.
Signature:
_10keystore.ListUsers() -> {users:[]string}
Example Call:
_10curl -X POST --data '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"keystore.listUsers"_10}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
Example Response:
_10{_10 "jsonrpc": "2.0",_10 "id": 1,_10 "result": {_10 "users": ["myUsername"]_10 }_10}