Skip to content

KeyChain sample commands

Avvrik edited this page Dec 4, 2018 · 23 revisions

This is a shortcut to the commands that help you interact with KeyChain. You can find full comprehensive descriptions of all the commands in the Protocol.

NB:

Please remember that you need to insert your own key name in the parameters when copying the requests!

Create command

{
  "command": "create",
  "params":
   {
      "keyname": "my key",
      "encrypted": true,
      "curve": "secp256k1",
      "cipher": "aes256"
  }
}

Parameters curve and cipher are saved in the key file during creation. Later, when the key file is used, compatibility of curve with kind is compared during sign, public_key commands, etc.

Possible values for blockchain_type: bitshares, array, ethereum, bitcoin.

Sign_hex command

{
  "command": "sign_hex",
  "params":
  {
    "chainid": "de5f4d8974715e20f47c8bb609547c9e66b0b9e31d521199b3d8d6af6da74cb1",
    "transaction": "871689d060721b5cec5a010080841e00000000000011130065cd1d0000000000000000",
    "blockchain_type": "array",
    "keyname": "my key@be5f6e75878b84ba"
  }
}

Sign_hash command

{
  "command": "sign_hash",
  "params":
  {
    "sign_type": "VRS_canonical",//default RSV_noncanonical
    "hash": "fe5e4a8974715e20f47c8bb609547c9e66b0b9e31d521199b3d8d6af6da74cb1",
    "keyname": "my key@be5f6e75878b84ba"
  }
}

Parameter sign_type determines the signature structure and whether the signature is canonical.

Possible values for sign_type:

  • VRS_canonical ,
  • RSV_noncanonical - default value.

Prefix RSV/VRS means signature struct: [R, S, v] or [v, R, S]

List command

{
  "command": "list"
}

Public_key command

{ 
  "command": "public_key",
  "params": 
  {
    "keyname": "my key@be5f6e75878b84ba"
  }
}

Set_unlock_time command

{
  "command": "set_unlock_time", 
  "params": 
  {
    "seconds": 100
  }
}

This command sets the timeout for the unlocked keys. After passphrase entry, the decrypted private key is stored in the memory during this time. Default unlock time = 0.

Unlock command

{  
  "command": "unlock", 
  "params": 
  { 
    "keyname": "my key@e08a1dee52cc68ee"
  }
}

Unlock private key. This allows to sign a transaction without passphrase entry. First, you must perform set_unlock_time command to set nonzero unlock time. Note that implicit unlocking will be performed after the commands sign_hex and sign_hash.

Lock command

{  
  "command": "lock"
}

Locks all unlocked keys.