2.2 cleos-commands-wallet

钱包常用命令

1. 创建钱包

$ cleos wallet create --to-console
$ cleos wallet create --name test --to-console
warn  2019-07-22T11:37:26.463 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./test.wallet
Creating wallet: test
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JmHrA1RwBAz79Sj7zjaYU1udPPDHqALDXLxMbqVV58MdVocTf1"

2. 打开钱包

打开一个已经存在的钱包。使用方式 cleos wallet open [OPTIONS]。

$ cleos wallet open
$ cleos wallet open --name test
Opened: test

3. 锁住钱包

锁住钱包。使用方式 cleos wallet lock [OPTIONS]。

$ cleos wallet lock
$ cleos wallet lock --name test
Locked: test

4. 锁住所有钱包

锁住所有的钱包。使用方式 cleos wallet lock_all。

cleos wallet lock_all
Locked All Wallets

5. 解锁钱包

解锁钱包。使用方式 cleos wallet unlock [OPTIONS]。

$ cleos wallet unlock --password PW5KCzAhiEtadFUeQZkgyttHrVLdQY8eXsMr6BxV8G6vbj3vnN1pz
Unlocked: default
$ cleos wallet unlock --name test --password PW5JmHrA1RwBAz79Sj7zjaYU1udPPDHqALDXLxMbqVV58MdVocTf1
Unlocked: test

6. 将密钥导入到钱包

$ cleos wallet import
$ cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
warn  2019-07-22T11:53:27.356 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./default.wallet
imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos wallet import --name test --private-key 5KQogwVYYateeo9K6agtYHnQs6e4qUoiLCT1PyeNP86eii9ogiK
warn  2019-07-22T11:48:49.393 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./test.wallet
imported private key for: EOS84TxMpRxAdaZBFXTzeg44NNB6R28avzYqhPTbhAZ361uWwkZfQ

7. 删除密钥

从钱包中删除密钥。使用方式 cleos wallet remove_key [OPTIONS] key。

$ cleos wallet remove_key EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos wallet remove_key EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV --password PW5KCzAhiEtadFUeQZkgyttHrVLdQY8eXsMr6BxV8G6vbj3vnN1pz
warn  2019-07-22T11:52:27.639 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./default.wallet
removed private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos wallet remove_key EOS84TxMpRxAdaZBFXTzeg44NNB6R28avzYqhPTbhAZ361uWwkZfQ --name test --password PW5JmHrA1RwBAz79Sj7zjaYU1udPPDHqALDXLxMbqVV58MdVocTf1
warn  2019-07-22T11:56:00.048 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./test.wallet
removed private key for: EOS84TxMpRxAdaZBFXTzeg44NNB6R28avzYqhPTbhAZ361uWwkZfQ

8. 创建私钥

在钱包中创建私钥。使用方式 cleos wallet create_key [OPTIONS] [key_type]。

$ cleos wallet create_key
warn  2019-07-22T11:56:37.703 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./default.wallet
Created new private key with a public key of: "EOS5V7im4FoVYUfKRffgDWcsBLDTs3ydp2QMc8bRtRrQy2Cqvvhdt"
$ cleos wallet create_key K1 --name test
warn  2019-07-22T11:59:28.332 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./test.wallet
Created new private key with a public key of: "EOS8f8JMZsmJtCVzsDrA4rqZeT3kHS3kg788it2BU28Ja8UPHLRUR"
$ cleos wallet create_key R1 --name test
warn  2019-07-22T11:59:45.194 thread-0  wallet.cpp:223                save_wallet_file     ] saving wallet to file /home/furnace/eosio-wallet/./test.wallet
Created new private key with a public key of: "PUB_R1_8XcLN7nHHqZYVT4K11pz2Dh7shPwc4XwCkPG2mcQTbkNtaq3zr"

9. 显示已打开的钱包列表

显示已打开的钱包列表,* 代表已打开。使用方式 cleos wallet list。

$ cleos wallet list
Wallets:
[
  "default *",
  "test *"
]

10. 查询钱包中已导入的公钥

$ cleos wallet keys
[
  "EOS4uusoq2pksEFDf6nYsYE1whFyffdrjvYDZXXtAzBMB5HrXeqLP",
  "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
  "PUB_R1_8XcLN7nHHqZYVT4K11pz2Dh7shPwc4XwCkPG2mcQTbkNtaq3zr"
]

11. 查询钱包中已导入的公钥-私钥对

$ cleos wallet private_keys
$ cleos wallet private_keys --password PW5KCzAhiEtadFUeQZkgyttHrVLdQY8eXsMr6BxV8G6vbj3vnN1pz
password: [[
    "EOS4uusoq2pksEFDf6nYsYE1whFyffdrjvYDZXXtAzBMB5HrXeqLP",
    "5JU8kmoqeVxJGvk1sSsbkpUBg1qTA24U9BQ6aziND7zx2zJG14g"
  ],[
    "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
    "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
  ]
]
$ cleos wallet private_keys --name test --password PW5JmHrA1RwBAz79Sj7zjaYU1udPPDHqALDXLxMbqVV58MdVocTf1
[[
    "EOS84TxMpRxAdaZBFXTzeg44NNB6R28avzYqhPTbhAZ361uWwkZfQ",
    "5KQogwVYYateeo9K6agtYHnQs6e4qUoiLCT1PyeNP86eii9ogiK"
  ],[
    "EOS8f8JMZsmJtCVzsDrA4rqZeT3kHS3kg788it2BU28Ja8UPHLRUR",
    "5JLd22j6GG2M7Jg4UvUpqh2dqnuVNkbKN5havjxQiKkjNppG5J9"
  ],[
    "PUB_R1_8XcLN7nHHqZYVT4K11pz2Dh7shPwc4XwCkPG2mcQTbkNtaq3zr",
    "PVT_R1_CEepzdL1wVq1SbjEi7nfJTVt5Gp1jhnXBEpsU7uLo45DV9zHb"
  ]
]

12. 停止 keosd

停止 keosd。使用方式 cleos wallet stop。

$ cleos wallet stop
Failed to connect to keosd at unix:///home/furnace/eosio-wallet/keosd.sock; is keosd running?

项目源代码

项目源代码会逐步上传到 Github,地址为 https://github.com/windstamp/blockchain。

Contributor

  1. Windstamp, https://github.com/windstamp

你可能感兴趣的:(2.2 cleos-commands-wallet)