如何用cetcli命令行工具生成地址

如何用cetcli命令行工具生成地址

cetcli有多个子命令,每个子命令下面有多个二级或三级子命令,每一级都可以通过 -h flag查看帮助,本节仅介绍生成地址及账户私钥所相关的命令

获取cetcli命令行工具

cetcli命令行工具届时开发团队会公布,选取对应版本下载即可

生成账户地址

cetcli keys add 命令用来生成账户地址,同时也会在本地添加相应账户的密钥

执行下面的命令可以在本地添加一个密钥,并将其与本地密钥的别名bob相关联:

注意 1: >>>帐户的助记词会在这个命令中输出, 请一定记得保管!!!!!!<<<

注意 2: >>>你的keystore文件默认会存储在: $HOME/.cetcli/ 中, 请一定备份这个目录<<<

注意 3: >>>需要记住创建帐户时输入的keystore passphrase, 后续使用相应帐户时需要输入此密码<<<

$ ./cetcli keys add bob
Enter a passphrase to encrypt your key to disk:
Repeat the passphrase:

- name: bob
  type: local
  address: coinex1yngg90rrmuq4ekwduv9w0zquv2vvxgs0z0g0md
  pubkey: coinexpub1addwnpepqwwxs8wyxrv4426qzkz4jnryppaa06795yjsjn2cj52l5xzr95n820yt9e0
  mnemonic: ""
  threshold: 0
  pubkeys: []


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

diary wheat renew excite knee excuse torch flush moon oak sunset solid artefact icon visual cave wave moment often glory wink witness girl call

查看本地账户地址

cetcli keys show命令用来查看密钥信息:

$ ./cetcli keys show bob
- name: bob
  type: local
  address: coinex1yngg90rrmuq4ekwduv9w0zquv2vvxgs0z0g0md
  pubkey: coinexpub1addwnpepqwwxs8wyxrv4426qzkz4jnryppaa06795yjsjn2cj52l5xzr95n820yt9e0
  mnemonic: ""
  threshold: 0
  pubkeys: []

账户密钥的导入导出

账户密钥的导出

cetcli keys export命令用来导出账户密钥,参数bob指定需要导出的账户

注意 : >>>需要妥善保管导出的内容,任何人都可以通过此内容恢复对账户的控制权!!!!!!<<<

$ ./cetcli keys export bob
Enter passphrase to decrypt your key:
Enter passphrase to encrypt the exported key:
-----BEGIN TENDERMINT PRIVATE KEY-----
kdf: bcrypt
salt: 87678F4622F4891B725AD041E23AD50D

U7Tup/dptclq1tpm2nfrNJ+6oFjaQs7ej2uCbtukNbHy13gudO7nBoQu6+uaIwje
QY2mLXwVq04+CkcCNpqPJQJGGl6YuLziWQSkGx4=
=1HCg
-----END TENDERMINT PRIVATE KEY-----

账户密钥的导入

cetcli keys import命令用来导入账户密钥,在本地恢复账户

提供包含上述内容的文件:keys.txt

为导入的账户密钥命名一个本地别名

输入创建帐户时的keystore passphrase

$ ./cetcli keys import bob_import keys.txt
Enter passphrase to decrypt your key:
$

此时账户密钥即导入在本地,默认keystore文件存储在$HOME/.cetcli/目录,cetcli keys show查看到:

$ ./cetcli keys show bob_import
- name: bob_import
  type: local
  address: coinex1yngg90rrmuq4ekwduv9w0zquv2vvxgs0z0g0md
  pubkey: coinexpub1addwnpepqwwxs8wyxrv4426qzkz4jnryppaa06795yjsjn2cj52l5xzr95n820yt9e0
  mnemonic: ""
  threshold: 0
  pubkeys: []

通过cetcli导入助记词

如果已经在ViaWallet等应用中创建过地址并保存了助记词,可以通过cetcli keys add 命令的flag:--recover导入助记词

注意 1: >>>你的keystore文件默认将会存储在: $HOME/.cetcli/ 中, 请一定备份这个目录<<<

注意 2: >>>需要记住相应帐户的keystore passphrase, 后续使用相应帐户需要输入此密码<<<

$ export KEY_NAME=bob
$ ./cetcli keys add ${KEY_NAME} --recover
Enter a passphrase to encrypt your key to disk:
Repeat the passphrase:
> Enter your bip39 mnemonic
kitchen keen toe vault elder legal robust hen month hold monkey add taste rocket cheap elevator foil face hold gossip attitude flavor thought thought

- name: bob
   type: local
   address: coinex17j0tajnkyu7pk8slgt4s9xtqnl0fmum3fll8lq
   pubkey: coinexpub1addwnpepqf0ha2nm5hh8szq59phrtu2yxd6veyfq0mgkxeydpcy7q3h2kq08jhy4fjx
   mnemonic: ""
   threshold: 0
   pubkeys: []

MISC

cetcli keys update 更新相应帐户的keystore passphrase

./cetcli keys update bob
Enter the current passphrase:
Enter the new passphrase:
Repeat the new passphrase:
Password successfully updated!

cetcli keys list列出本地所有的账户密钥

cetcli keys list
- name: alice
  type: local
  address: coinex1teh5ua26fcxayeecz6pku0c3gtg9l3wsfpg5wr
  pubkey: coinexpub1addwnpepqd4hw6ux0muts3fjdg0xm29hkkhkz4jma0eqgx7glt6tqh7cmz785uepfal
  mnemonic: ""
  threshold: 0
  pubkeys: []
- name: bob
  type: local
  address: coinex1yngg90rrmuq4ekwduv9w0zquv2vvxgs0z0g0md
  pubkey: coinexpub1addwnpepqwwxs8wyxrv4426qzkz4jnryppaa06795yjsjn2cj52l5xzr95n820yt9e0
  mnemonic: ""
  threshold: 0
  pubkeys: []

还有其他命令等大家可自行通过cetcli keys -h查看

1 Like