oflyhigh avatar

HIVE上使用steem-python的一些尝试:续一 (见证人上下线 & claim reward)

oflyhigh

Published: 23 Mar 2020 › Updated: 23 Mar 2020HIVE上使用steem-python的一些尝试:续一 (见证人上下线 & claim reward)

HIVE上使用steem-python的一些尝试:续一 (见证人上下线 & claim reward)

原本以为经过一番研究,已经搞定了steem-python在Hive上的使用,不过今天在尝试claim_reward时却一直出错。


(图源 :pixabay)

被claim_reward 折磨大半天

其实claim_reward的代码很简单:

steem = Steem()
steem.commit.claim_reward_balance(account = 'oflyhigh')

但是却一直提示如下错误:

missing required posting authority:Missing Posting Authority oflyhigh

研究了大半天,各种修改和调试,但是错误提示又变成了:

Assert Exception:is_asset_type( reward_sbd, SBD_SYMBOL ): Reward Steem must be HBD

这是什么鬼?总之就是我折腾大半天,折腾得脑壳疼,也没搞定这个问题。

steem-python处理hive见证人

然后这时候有朋友喊我看看如何用steem-python在hive这边下线见证人,于是我尝试执行如下指令:

steempy witnessupdate --witness oflyhigh --signing_key STM1111111111111111111111111111111114T1Anm

Transaction长成这样:

image.png

错误还是:missing required active authority:Missing Active Authority oflyhigh

再回头看tansaction里'fee': '0.000 STEEM' 以及'account_creation_fee': '3.000 HIVE'竟然又有STEEM,又有HIVE,是不是很怪异?

于是我首先在steem/commit.py文件中,将如下代码中的fee部分中STEEM改成HIVE:

image.png

再执行见证人下线指令:

image.png

结果错误依旧:missing required active authority:Missing Active Authority oflyhigh

那么都改成STEEM呢?于是将上述代码恢复,并通过见证人指令写入account_creation_fee,指令如下:

steempy witnessupdate --witness oflyhigh --account_creation_fee 3.000 --signing_key STM1111111111111111111111111111111114T1Anm

transaction如下:

image.png

然后发现,竟然成功了,在https://hiveblocks.com/@oflyhigh 可以看到成功执行的信息:
image.png

既然下线搞定了,那么上线也没啥问题:

steempy witnessupdate --witness oflyhigh --account_creation_fee 3.000 --signing_key STM6FwqfX8N3DxFZA6zDCE6GMq5TcCTH21XWLtzQMp6vQLwCFbRyo

再回到claim_reward_balance

原本已经被claim_reward_balance折磨麻木的脑壳,在弄完见证人上下线功能后,突然就有了灵感,应该就是币名不一致导致的签名校验不通过。

而由于HIVE从STEEM迁移过来,代码中可能存在一些STEEM/SBD相关的残留,所以用HIVE/HBD签名,就会导致失败。

那么既然如此,claim_reward_balance是不是也可以完全用STEEM/SBD来处理?在steem/commit.py中claim_reward_balance函数里改动两行:

将:

reward_steem = a['reward_steem_balance']"
reward_sbd = a['reward_sbd_balance']"

改成:

reward_steem = a['reward_steem_balance'].split(" ")[0] + " STEEM"
reward_sbd = a['reward_sbd_balance'].split(" ")[0] + " SBD"

再测试claim_reward_balance,竟然神奇地通过了:

image.png

https://hiveblocks.com/@oflyhigh 可以看到成功执行的信息:

image.png

困扰我大半天的问题,竟因为去解决别的问题得到启发,一下子就解决了,真是太魔幻了。这回应该可以愉快地玩耍啦。

相关链接

Leave HIVE上使用steem-python的一些尝试:续一 (见证人上下线 & claim reward) to:

Written by

Programmer, Maker, Freelancer, Witness. Make friends, Make money, Make life better!

Read more #cn posts


Best Posts From oflyhigh

We have not curated any of oflyhigh's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From oflyhigh