
1,摘要
【本文目标】
通过本文学习,可以通过EOS本地环境完成EOS注册账号的active key和owner key的变更。
在EOS账号是其他人代为注册时,私钥往往也被其他人知晓,存在泄漏风险,建议尽快完成变更。
【前置条件】
1)参考第8课 如何使用开发环境命令行注册EOS靓号?文章,已完成了靓号的注册和环境搭建。
【技术收获】
1) cleos set account permission的使用;
2. 实践操作
承接上一课的故事,戈壁创投的徐晨总请辉哥注册个他们公司同名的EOS账号(例如:gobipartners)。近期,戈壁创投决定要投资某个优质区块链项目,准备往gobipartners账号打100万个EOS,作为区块链投资转账总出口账号。徐总突然想起,gobipartners账号的私钥也是辉哥创建的,他可能也保留着该账户的私钥记录,吓出了一身冷汗。
现在徐晨总也知道可以通过一些钱包生成密钥对,这个密钥对只有他自己知晓。
2.1 通过TokenPocket钱包创建密钥对
通过TokenPocket官网下载钱包版本。
安装后,通过 发现 > EOS助手 > 账号注册 > 密码生成器 完成密钥对的生成。



2.2 密钥导入
徐总来到辉哥的本地EOS环境,让辉哥背过身,亲自把私钥导入辉哥的duncanwang本地钱包。
【说明】此步操作可以在别的任意EOS开发环境完成导入工作。
cleos wallet import <新的私钥> -n duncanwang
2.3 权限变更
1) 查看gobipartners账号信息
cleos -u https://node1.eoscannon.io get account gobipartners
输出结果表明 owner key 和 active key还是辉哥的密钥对。
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners
permissions:
owner 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
active 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
memory:
quota: 7.959 KiB used: 2.926 KiB
net bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 55.92 KiB
limit: 55.92 KiB
cpu bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 0 us
available: 10.9 ms
limit: 10.9 ms
2.4 变更账户active权限为徐总公钥
假设徐总产生的公钥Public key如下:EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
命令格式:
cleos set account permission <转让账户名> active '{"threshold":1,"keys":[{"key":"<对方公钥>","weight":1}]}' owner
输出结果:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io set account permission gobipartners active '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' owner
executed transaction: 0b7ab9fe92413e6b4b5d25578afdef81438c73adac015972ce56f59c570034e9 160 bytes 1317 us
# eosio <= eosio::updateauth {"account":"gobipartners","permission":"active","parent":"owner","auth":{"threshold":1,"keys":[{"key...
warning: transaction executed locally, but may not be confirmed by the network yet
查询确认active的KEY已发生变更:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners
permissions:
owner 1: 1 EOS8gaYL4uHyAiZjviwNJ8CdY31xikYtQfexyUfkNUnDqhNpnYXQR
active 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
memory:
quota: 7.959 KiB used: 2.926 KiB
net bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 161 bytes
available: 55.76 KiB
limit: 55.92 KiB
cpu bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 1.122 ms
available: 9.779 ms
limit: 10.9 ms
2.5 变更账户owner为徐总公钥
命令格式:
cleos set account permission <转让账户名> owner '{"threshold":1,"keys":[{"key":"<对方公钥>","weight":1}]}' -p <转让账户名>@owner
输出结果:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io set account permission -x 120 gobipartners owner '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' -p gobipartners@owner
executed transaction: ed1593fee153baa7b02e1e3e1155e732c3e7db4fbb3fd50ff73b0de1a04d5831 160 bytes 1186 us
# eosio <= eosio::updateauth {"account":"gobipartners","permission":"owner","parent":"","auth":{"threshold":1,"keys":[{"key":"EOS...
warning: transaction executed locally, but may not be confirmed by the network yet
【问题】
输入命令提示错误,信息如下:
duncanwang@duncanwang:~$ cleos set account permission gobipartners owner '{"threshold":1,"keys":[{"key":"EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V","weight":1}]}' -p gobipartners@owner
Error 3090003: provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
初步估计是跟主网节点连接处理的时间不够,增加-x 120,把等待时间改为2分钟,就成功了。
查询确认owner的KEY已发生变更:
duncanwang@duncanwang:~$ cleos -u https://node1.eoscannon.io get account gobipartners
permissions:
owner 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
active 1: 1 EOS7Rq86JcZLgPXwZKRGPYUnLayBy7NcBV7FBE7gSNCW3HmGApK9V
memory:
quota: 7.959 KiB used: 2.926 KiB
net bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 318 bytes
available: 55.61 KiB
limit: 55.92 KiB
cpu bandwidth:
delegated: 0.1000 EOS (total staked delegated to account from others)
used: 1.628 ms
available: 9.273 ms
limit: 10.9 ms
4,参考
1) 创建EOS主网账户
本故事纯属虚构,辉哥还没有跟徐晨总建立联系。但是戈壁创投的EOS帐号已注册好了,如有需要可转让给徐总。
网友评论