Hive Wallet迟迟不能用,如果想要转移资产该怎么办?

in #cn4 years ago

Hive已经推出好几天了,但其钱包功能一直不能用,每次点击“Wallet”时,都会给出一个很不友好的出错页面:

image.png

那么,如果真的需要将自己持有的Hive / HBD等转移到其他账号,或者交易所的话,该如何做呢?其实也很简单,只需要写几行Python代码就可以实现这样的功能。我这里使用的是hive-python,但里面有个坑需要填。具体请看这篇文章:如何在Hive上使用hivepy

具体代码就很简单了:

import sys
from hive import Hive
from hive.account import Account

if len(sys.argv) !=7:
  print ('Usage: transfer.py ACCOUNT ACTIVE_KEY TO AMOUNT HBD/HIVE MEMO')
  exit()

_from       = sys.argv[1]
_active_key = sys.argv[2]
_to         = sys.argv[3]
_amount     = float(sys.argv[4])
_type       = sys.argv[5]
_memo       = sys.argv[6]

wif = {
  "active": _active_key
}
hive = Hive(keys=wif)

account = Account(_from)
hbdbalance  = float(account.balances["available"]["HBD"])
hivebalance = float(account.balances["available"]["HIVE"])
if _type=='HBD' and hbdbalance < _amount:
  print("Account balance low: %s" % (str(hbdbalance)))
  exit()
if _type=='HIVE' and hivebalance < _amount:
  print("Account balance low: %s" % (str(steembalance)))
  exit()

hive.transfer(_to, _amount, _type, memo=_memo, account=_from)
print ("transferred %s %s to %s" % (str(_amount),_type,_to))

运行:

 python transfer.py aafeng YOUR_ACTIVE_KEY aafeng.test 0.001 HIVE test

从hiveblocks可以看到转账已经成功。

image.png