Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change some public attributes to properties to eliminate potential problems #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SanyueHan
Copy link

@SanyueHan SanyueHan commented May 5, 2022

Hello,
I'm a beginner but I noticed that there might be a small problem in the PrivateKey class:
In this class, you defined balance, unspents, and transactions as public attributes, but initialized them with zero or vacant list.
If you instantiate a prv key obj without calling get_balance()/get_unspents()/get_transactions() methods, the result of key.balance, key.unspents, key.transactions are all wrong.
This may be misleading and may trigger potential bugs if your package is used without attention because the public attributes look like properties.
A good solution is to make these attributes protected and create their corresponding properties, leaving the interface unchanged while solving the consistency problem, just like the self._address attribute does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant