Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit ebc508a

Browse files
committed
Release of 0.20.0
* Fully supporting hf20 * add get_resource_params(), get_resource_pool(), claim_account(), create_claimed_account() to Steem * fix 30x fee for create_account * add find_rc_accounts() to Blockchain * get_rc(), get_rc_manabar(), get_manabar() added to Account * get_voting_power() fixed
1 parent 76021f3 commit ebc508a

5 files changed

Lines changed: 331 additions & 20 deletions

File tree

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Changelog
22
=========
3+
0.20.0
4+
------
5+
* Fully supporting hf20
6+
* add get_resource_params(), get_resource_pool(), claim_account(), create_claimed_account() to Steem
7+
* fix 30x fee for create_account
8+
* add find_rc_accounts() to Blockchain
9+
* get_rc(), get_rc_manabar(), get_manabar() added to Account
10+
* get_voting_power() fixed
11+
312
0.19.57
413
--------
514
* last hf19 release

beem/account.py

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ def getSimilarAccountNames(self, limit=5):
221221
"""Deprecated, please use get_similar_account_names"""
222222
return self.get_similar_account_names(limit=limit)
223223

224+
def get_rc(self):
225+
"""Return RC of account"""
226+
b = Blockchain(steem_instance=self.steem)
227+
return b.find_rc_accounts(self["name"])
228+
229+
def get_rc_manabar(self):
230+
"""Returns current_mana and max_mana for RC"""
231+
rc_param = self.get_rc()
232+
max_mana = int(rc_param["max_rc"])
233+
last_update = datetime.utcfromtimestamp(rc_param["rc_manabar"]["last_update_time"])
234+
diff_in_seconds = (addTzInfo(datetime.utcnow()) - addTzInfo(last_update)).total_seconds()
235+
current_mana = rc_param["rc_manabar"]["current_mana"] + diff_in_seconds * max_mana / (5 * 24 * 60 * 60)
236+
return {"current_mana": current_mana, "max_mana": max_mana}
237+
224238
def get_similar_account_names(self, limit=5):
225239
""" Returns ``limit`` account names similar to the current account
226240
name as a list
@@ -289,6 +303,11 @@ def print_info(self, force_refresh=False, return_str=False, use_table=False, **k
289303
used_kb = bandwidth["used"] / 1024
290304
allocated_mb = bandwidth["allocated"] / 1024 / 1024
291305
last_vote_time_str = formatTimedelta(addTzInfo(datetime.utcnow()) - self["last_vote_time"])
306+
try:
307+
rc_mana = self.get_rc_manabar()
308+
except:
309+
rc_mana = None
310+
292311
if use_table:
293312
t = PrettyTable(["Key", "Value"])
294313
t.align = "l"
@@ -302,6 +321,9 @@ def print_info(self, force_refresh=False, return_str=False, use_table=False, **k
302321
if bandwidth["allocated"] > 0:
303322
t.add_row(["Remaining Bandwidth", "%.2f %%" % (remaining)])
304323
t.add_row(["used/allocated Bandwidth", "(%.0f kb of %.0f mb)" % (used_kb, allocated_mb)])
324+
if rc_mana is not None:
325+
t.add_row(["Remaining RC", "%.2f %%" % (rc_mana["current_mana"] / rc_mana["max_mana"] * 100)])
326+
t.add_row(["used/allocated RC", "(%.0f of %.0f)" % (rc_mana["current_mana"], rc_mana["max_mana"])])
305327
if return_str:
306328
return t.get_string(**kwargs)
307329
else:
@@ -318,7 +340,11 @@ def print_info(self, force_refresh=False, return_str=False, use_table=False, **k
318340
if bandwidth["allocated"] > 0:
319341
ret += "--- Bandwidth ---\n"
320342
ret += "Remaining: %.2f %%" % (remaining)
321-
ret += " (%.0f kb of %.0f mb)" % (used_kb, allocated_mb)
343+
ret += " (%.0f kb of %.0f mb)\n" % (used_kb, allocated_mb)
344+
if rc_mana is not None:
345+
ret += "--- RC manabar ---\n"
346+
ret += "Remaining: %.2f %%" % (rc_mana["current_mana"] / rc_mana["max_mana"] * 100)
347+
ret += " (%.0f of %.0f)" % (rc_mana["current_mana"], rc_mana["max_mana"])
322348
if return_str:
323349
return ret
324350
print(ret)
@@ -337,38 +363,51 @@ def get_reputation(self):
337363
rep = int(self['reputation'])
338364
return reputation_to_score(rep)
339365

366+
def get_manabar(self):
367+
""""Return manabar"""
368+
max_mana = int(self.get_vests())
369+
last_update = datetime.utcfromtimestamp(self["voting_manabar"]["last_update_time"])
370+
diff_in_seconds = (addTzInfo(datetime.utcnow()) - addTzInfo(last_update)).total_seconds()
371+
current_mana = int(self["voting_manabar"]["current_mana"]) + diff_in_seconds * max_mana / (5 * 24 * 60 * 60)
372+
return {"current_mana": current_mana, "max_mana": max_mana}
373+
340374
def get_voting_power(self, with_regeneration=True):
341375
""" Returns the account voting power in the range of 0-100%
342376
"""
343377
if with_regeneration:
344378
regenerated_vp = 0
345-
if "last_vote_time" in self:
379+
if "voting_manabar" in self:
380+
last_vote_time = datetime.utcfromtimestamp(self["voting_manabar"]["last_update_time"])
381+
diff_in_seconds = (addTzInfo(datetime.utcnow()) - addTzInfo(last_vote_time)).total_seconds()
382+
regenerated_vp = diff_in_seconds * STEEM_100_PERCENT / STEEM_VOTING_MANA_REGENERATION_SECONDS / 100
383+
elif "last_vote_time" in self:
346384
last_vote_time = self["last_vote_time"]
347385
diff_in_seconds = (addTzInfo(datetime.utcnow()) - (last_vote_time)).total_seconds()
348386
regenerated_vp = diff_in_seconds * STEEM_100_PERCENT / STEEM_VOTE_REGENERATION_SECONDS / 100
349-
elif "voting_manabar" in self:
350-
last_vote_time = self["voting_manabar"]["last_update_time"]
351-
diff_in_seconds = (addTzInfo(datetime.utcnow()) - (last_vote_time)).total_seconds()
352-
regenerated_vp = diff_in_seconds * STEEM_100_PERCENT / STEEM_VOTING_MANA_REGENERATION_SECONDS / 100
353387
else:
354388
regenerated_vp = 0
355389
if "voting_power" in self:
356390
total_vp = (self["voting_power"] / 100 + regenerated_vp)
357391
elif "voting_manabar" in self:
358-
total_vp = int(self["voting_manabar"]["current_mana"]) / 100 + regenerated_vp
392+
total_vp = int(self["voting_manabar"]["current_mana"]) / int(self.get_vests()) + regenerated_vp
359393
if total_vp > 100:
360394
return 100
361395
if total_vp < 0:
362396
return 0
363397
return total_vp
364398

365-
def get_steem_power(self, onlyOwnSP=False):
366-
""" Returns the account steem power
399+
def get_vests(self, only_own_vests=False):
400+
""" Returns the account vests
367401
"""
368402
vests = (self["vesting_shares"])
369-
if not onlyOwnSP and "delegated_vesting_shares" in self and "received_vesting_shares" in self:
403+
if not only_own_vests and "delegated_vesting_shares" in self and "received_vesting_shares" in self:
370404
vests = vests - (self["delegated_vesting_shares"]) + (self["received_vesting_shares"])
371-
return self.steem.vests_to_sp(vests)
405+
return vests
406+
407+
def get_steem_power(self, onlyOwnSP=False):
408+
""" Returns the account steem power
409+
"""
410+
return self.steem.vests_to_sp(self.get_vests(only_own_vests=onlyOwnSP))
372411

373412
def get_voting_value_SBD(self, voting_weight=100, voting_power=None, steem_power=None, not_broadcasted_vote=True):
374413
""" Returns the account voting value in SBD
@@ -437,7 +476,7 @@ def get_recharge_timedelta(self, voting_power_goal=100):
437476
missing_vp = voting_power_goal - self.get_voting_power()
438477
if missing_vp < 0:
439478
return 0
440-
recharge_seconds = missing_vp * 100 * STEEM_VOTE_REGENERATION_SECONDS / STEEM_100_PERCENT
479+
recharge_seconds = missing_vp * 100 * STEEM_VOTING_MANA_REGENERATION_SECONDS / STEEM_100_PERCENT
441480
return timedelta(seconds=recharge_seconds)
442481

443482
def get_recharge_time(self, voting_power_goal=100):

beem/blockchain.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,3 +910,31 @@ def get_similar_account_names(self, name, limit=5):
910910
return account["accounts"]
911911
else:
912912
return self.steem.rpc.lookup_accounts(name, limit)
913+
914+
def find_rc_accounts(self, name):
915+
""" Returns limit similar accounts with name as list
916+
917+
:param str name: account name to search rc params for (can also be a list of accounts)
918+
:returns: RC params
919+
:rtype: list
920+
921+
.. code-block:: python
922+
923+
>>> from beem.blockchain import Blockchain
924+
>>> blockchain = Blockchain()
925+
>>> ret = blockchain.find_rc_accounts("test")
926+
>>> len(ret) == 1
927+
True
928+
929+
"""
930+
if not self.steem.is_connected():
931+
return None
932+
self.steem.rpc.set_next_node_on_empty_reply(False)
933+
if isinstance(name, list):
934+
account = self.steem.rpc.find_rc_accounts({'accounts': name}, api="rc")
935+
if bool(account):
936+
return account["rc_accounts"]
937+
else:
938+
account = self.steem.rpc.find_rc_accounts({'accounts': [name]}, api="rc")
939+
if bool(account):
940+
return account["rc_accounts"][0]

beem/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,12 +2004,12 @@ def witnesscreate(witness, pub_signing_key, maximum_block_size, account_creation
20042004
@cli.command()
20052005
@click.argument('witness', nargs=1)
20062006
@click.argument('wif', nargs=1)
2007-
@click.option('--account_creation_fee', help='Account creation fee')
2008-
@click.option('--account_subsidy_budget', help='Max block size')
2009-
@click.option('--account_subsidy_decay', help='Max block size')
2007+
@click.option('--account_creation_fee', help='Account creation fee (float)')
2008+
@click.option('--account_subsidy_budget', help='Account subisidy per block')
2009+
@click.option('--account_subsidy_decay', help='Per block decay of the account subsidy pool')
20102010
@click.option('--maximum_block_size', help='Max block size')
20112011
@click.option('--sbd_interest_rate', help='SBD interest rate in percent')
2012-
@click.option('--new_signing_key', help='SBD interest rate in percent')
2012+
@click.option('--new_signing_key', help='Set new signing key')
20132013
@click.option('--url', help='Witness URL')
20142014
def witnessproperties(witness, wif, account_creation_fee, account_subsidy_budget, account_subsidy_decay, maximum_block_size, sbd_interest_rate, new_signing_key, url):
20152015
"""Update witness properties without pricefeed"""

0 commit comments

Comments
 (0)