账户安全,用多签保护账号

in hive-180932 •  6 months ago 

在区块链,私钥安全永远都是第一要素,一旦泄露,后果是很可怕的,特别是高权限的私钥泄露。

我们可以用多签的办法,来保护某些重要的账号,哪怕丢了一把私钥,也不至于完蛋了。

这里演示一下一个多签的代码,给owner权限和active权限都给加上多签。

from beem.steem import Steem
from beembase import operations
from beem.transactionbuilder import TransactionBuilder
from beembase.transactions import Signed_Transaction
from beem.account import Account

nodes = 'https://cn.steems.top'  # 节点
player = "maiyude"#用户名
key = "5JJxxxx"  # owner key

s = Steem(keys=[key], node=nodes)
account = Account(player, steem_instance=s)

who_owner = {'weight_threshold': 2, 'account_auths': [], 'key_auths': [
    ['STM8TR2bahWT8SorDpPxkEncBwxVbMUsJ4QQXViRDpfDeraqvAKon', 1],  # 用户1,owner公钥,权重1
    ['STM5cXriH9oMfB5ByWPaAjvWt9Wj6TW2cCh5yBr1oHikedbYU5qRr', 1],  # 用户2,owner公钥,权重1
    ['STM6fDG7HN8F5n1QYjW4PArp3HGc6hF8G1hNS2hBMuvFTWkc1Bdi4', 1]  # 用户3,owner公钥,权重1
]}


who_active = {'weight_threshold': 2, 'account_auths': [], 'key_auths': [
    ['STM8JF6BonaBpS2W6n7D5AFg4xUFbPZJ3D8a8dSZM5rhhiK2kbpYj', 1],  # 用户1,active公钥,权重1
    ['STM6kFLtnuXQ5W7S2BTwxCQbzr9FhThXi2XXjn5b5cUNtgM1xnnBg', 1],  # 用户2,active公钥,权重1
    ['STM5RWyH2bgiNz36NM5b5enE5XCMn2mqRVeNg5CchHyxTVoR8tjio', 1]  # 用户3,active公钥,权重1
]}
op = operations.Account_update(
    **{
        "account": account["name"],
        "json_metadata": account["json_metadata"],
        "owner": who_owner,
        "active":who_active,
        "memo_key": account["memo_key"]
    })

tx = TransactionBuilder(steem_instance=s)

tx.appendOps(op)
# 把签名添加并签名
tx.appendSigner(player, "owner")
#tx.appendSigner(player2, "owner")
tx.sign()

# 广播
tx.broadcast()
print("完成")

成功广播后,查询一下信息是否更改成功

image.png

成功更改,这个账号以后使用owner和active都需要2把私钥多签才能操作,一定程度安全了不少。

不过这样的操作最好用在重要的账号,因为这样做了,普通的转账都会变得麻烦起来,有利有弊吧。

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  6 months ago 

给鱼哥拍手支持👏
!shop

  ·  6 months ago 

你好鸭,maiyude!
@annepink赠送1枚SHOP币给你!

目前你总共有: 1枚SHOP币

查看或者交易 SHOP币 请到 steem-engine.com.

无聊吗?跟我猜拳吧! **石头,剪刀,布~**

啪啪拍拍拍拍