eos Error 3120003: Locked wallet 钱包锁住错误以及延长锁住时间

yufei       5 年, 4 月 前       2572

最近 EOS 合约开发和调试有一件事特烦,总是在不经意间,就碰到了 EOS 钱包被锁住的错误

cleos push action  micromsg send '["xiaoming","xiaohong","i miss you"]' -p xiaoming 
Error 3120003: Locked wallet
Ensure that your wallet is unlocked before using it!

这时候就需要解锁钱包了,钱包的密码就是创建的时候的密码,比如我的测试机密码就是

PW5KKXqdm94UCeQ3xSwCmsJy7PJjeHsht8qbYVbG6CUcm4pNJ6Gq2

解锁方式有两种:

  1. 先输入 cleos wallet unlock 命令再输入密码

    cleos wallet unlock
    password:
    

    输入密码后就会显示

    password: Unlocked: default
    
  2. 另一种方式,就是使用 --password 参数直接传递密码

    这种方式只推荐开发时使用

    cleos wallet unlock --password PW5KKXqdm94UCeQ3xSwCmsJy7PJjeHsht8qbYVbG6CUcm4pNJ6Gq2
    

    这种方式的好处就是快,不好之处就是相当于明文密码,使用 history 一下就知道密码是多少了,因此推荐开发时使用

当然了,作为程序员,本着偷懒的心,要是不用输入密码或者不用频繁的输入密码那该多好啊。

于是,我看了下 keosd 钱包的启动选项,还真被我发现了一些东西啊

keosd --help
Application Options:

Config Options for eosio::http_plugin:
  --unix-socket-path arg (=keosd.sock)  The filename (relative to data-dir) to 
                                        create a unix socket for HTTP RPC; set 
                                        blank to disable.
  --http-server-address arg             The local IP and port to listen for 
                                        incoming http connections; leave blank 
                                        to disable.
  --https-server-address arg            The local IP and port to listen for 
                                        incoming https connections; leave blank
                                        to disable.
  --https-certificate-chain-file arg    Filename with the certificate chain to 
                                        present on https connections. PEM 
                                        format. Required for https.
  --https-private-key-file arg          Filename with https private key in PEM 
                                        format. Required for https
  --access-control-allow-origin arg     Specify the Access-Control-Allow-Origin
                                        to be returned on each request.
  --access-control-allow-headers arg    Specify the Access-Control-Allow-Header
                                        s to be returned on each request.
  --access-control-max-age arg          Specify the Access-Control-Max-Age to 
                                        be returned on each request.
  --access-control-allow-credentials    Specify if Access-Control-Allow-Credent
                                        ials: true should be returned on each 
                                        request.
  --max-body-size arg (=1048576)        The maximum body size in bytes allowed 
                                        for incoming RPC requests
  --verbose-http-errors                 Append the error log to HTTP responses
  --http-validate-host arg (=1)         If set to false, then any incoming 
                                        "Host" header is considered valid
  --http-alias arg                      Additionaly acceptable values for the 
                                        "Host" header of incoming HTTP 
                                        requests, can be specified multiple 
                                        times.  Includes http/s_server_address 
                                        by default.

Config Options for eosio::wallet_plugin:
  --wallet-dir arg (=".")               The path of the wallet files (absolute 
                                        path or relative to application data 
                                        dir)
  --unlock-timeout arg (=900)           Timeout for unlocked wallet in seconds 
                                        (default 900 (15 minutes)). Wallets 
                                        will automatically lock after specified
                                        number of seconds of inactivity. 
                                        Activity is defined as any wallet 
                                        command e.g. list-wallets.
  --yubihsm-url URL                     Override default URL of 
                                        http://localhost:12345 for connecting 
                                        to yubihsm-connector
  --yubihsm-authkey key_num             Enables YubiHSM support using given 
                                        Authkey

Application Config Options:
  --plugin arg                          Plugin(s) to enable, may be specified 
                                        multiple times

Application Command Line Options:
  -h [ --help ]                         Print this help message and exit.
  -v [ --version ]                      Print version information.
  --print-default-config                Print default configuration template
  -d [ --data-dir ] arg                 Directory containing program runtime 
                                        data
  --config-dir arg                      Directory containing configuration 
                                        files such as config.ini
  -c [ --config ] arg (=config.ini)     Configuration file name relative to 
                                        config-dir
  -l [ --logconf ] arg (=logging.json)  Logging configuration file name/path 
                                        for library users

从帮助信息中我们发现了救星,就是那个 --unlock-timeout

 --unlock-timeout arg (=900)           Timeout for unlocked wallet in seconds 
                                        (default 900 (15 minutes)). Wallets 
                                        will automatically lock after specified
                                        number of seconds of inactivity. 
                                        Activity is defined as any wallet 
                                        command e.g. list-wallets.

这个参数用于设置钱包的锁定时间,默认时间是 900s 也就是 15 分钟,也就是说,只要我们超过了 15 分钟没有对钱包进行任何操作,钱包就会锁住

哈哈,也就是说,我们可以使用下面的方式设置钱包锁住时间

  1. 一小时

    keosd --unlock-timeout=3600
    
  2. 一天

    keosd --unlock-timeout=86400
    
  3. 一个月

    keosd --unlock-timeout=2592000
    
  4. 一年

    keosd --unlock-timeout=31536000
    

当然了,像我这种懒人,肯定要懒到底, 100 年

keosd --unlock-timeout=3153600000
目前尚无回复
简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.