[Beem] [Version: 0.20.19] Account.get_balance function shows summed value of liquid balance and unclaimed reward
Project Information
Repository: https://github.com/holgern/beem
Project Name: Beem
Expected behavior
from beem.account import Account
acc=Account("eftikhan")
inf=acc.get_balances()
steem=inf['available'][0]
sbd=inf['available'][1]
print("steem {} and sbd {}".format(steem, sbd))
Account.get_balance function should Return all account balances as dictionary. As i have filtered the steem and sbd here it should return the actual liquid balance of steem and sbd.
Actual behavior
When the Account.get_balance function is called, it shows the account's steem and sbd balance summed with unclaimed reward. on eftikhan
account the actual sbd balance is 0.412
but beem shows it 0.503
as it summed 0.091
unclaimed sbd which should not have happened here.
How to reproduce
from beem.account import Account
acc=Account("username")
inf=acc.get_balances()
steem=inf['available'][0]
sbd=inf['available'][1]
print("steem {} and sbd {}".format(steem, sbd))
Install latest version of beem and run this code.
Take an account which has unclaimed reward.
Put that account's username on username and run the code.
You will see the balance is showing more than steemit shows as it summed up the unclaimed reward.
Technical analysis
https://github.com/holgern/beem/blob/1364f732e94d9347682f2869eaec61553555ca63/beem/account.py#L917
over here you will see,
ret = []
for i in range(len(symbols)):
balance_sum = self.get_balance(self.available_balances, symbols[i])
balance_sum += self.get_balance(self.saving_balances, symbols[i])
balance_sum += self.get_balance(self.reward_balances, symbols[i])
ret.append(balance_sum)
return ret
This issue is happening because of += sign. From this we also came to know, it would sum up the the savings balance as well.
Possible fix
ret = []
for i in range(len(symbols)):
balance_sum = self.get_balance(self.available_balances, symbols[i])
balance_sum = balance_sum + self.get_balance(self.saving_balances, symbols[i])
balance_sum = balance_sum + self.get_balance(self.reward_balances, symbols[i])
ret.append(balance_sum)
return ret
Recording Of The Bug
Python 3.6
Beem version 0.20.19
Operating system: Ubuntu 18.06
Github Account
https://github.com/sourovafrin
Thanks for your contribution @sourovafrin
Awesome work, you found, reported and provided a recommended fix that was implemented in the project nice work. Great work, nice and easy to use solution and great detail surrounding the issue. Your steps were easy to follow and the video complimented the contribution nicely.
Maybe you could consider sending a PR when you come across something you can fix in future? It's not required in this category, but might be useful :)
Once again, thanks for your contribution and look forward to seeing more from you in the future :)
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @tobias-g! Keep up the good work!
As a PO, I can confirm that there is the described bug and I implemented the suggested solution. Thanks again.
Thank you for your time to confirm tbe bug.
And i also appreciate your quick respons.
Hi, @sourovafrin!
You just got a 0.47% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
Hi @sourovafrin, your post has been upvoted by @bdcommunity and the trail!
If you want to support us, please consider following our curation trail, setting us as your witness proxy, or delegating STEEM POWER to us.
JOIN US ON
Hi @sourovafrin!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @sourovafrin!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!