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

Altcoin integration #25

Closed
wants to merge 11 commits into from
Closed

Altcoin integration #25

wants to merge 11 commits into from

Conversation

peerchemist
Copy link
Contributor

My take on: #18

@@ -13,7 +13,8 @@
from base58 import b58encode_check, b58decode_check

from .bech32 import decode, encode
from ..setup import is_mainnet, net_name
from ..setup import net_name
from ..setup import NETWORKS
Copy link

@oskyk oskyk Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this 2 lines to one same in crypto.py

@oskyk
Copy link

oskyk commented Feb 17, 2018

Pretty good way to solve this problem.

@peerchemist
Copy link
Contributor Author

@SimoneBronzini any comments on this?

@SimoneBronzini
Copy link
Contributor

@peerchemist really sorry about the delay, will take a look at it as soon as possible. The next days might be a good time.

Copy link
Contributor

@SimoneBronzini SimoneBronzini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! Unfortunately, I ran the tests and they are failing. I fixed the two bugs that I underlined in the review but tests are still not passing.
However, as a more general note, I believe we should take a slightly different approach to this problem. In particular, I am not sure about two aspects:

  • having a Constants class that can be extended to BitcoinConstants, LitecoinConstants and so on and passed to setup: this looks like a way to add a new coin to the current library, although, such an addition, would be way more complex than just defining a new Constants class and would require huge changes in the codebase. So, I think a better approach would be of course segregating all the constants and making them easily editable, but in a static way. By this I mean that who wants to implement an altcoin version of this library can fork it, change all the constants in one single place and change the codebase where needed.
  • having all modules access a global dictionary with the constants: I believe this greatly reduces code readability

I will soon submit a PR that should avoid both these problems, so that we can review and discuss it together.
I think I will also remove the 'regtest' option from setup, it has never made much sense to have it anyway.

@@ -20,7 +20,8 @@

from ..lib.types import HexSerializable
from ..lib.parsing import Stream, Parser
from ..setup import is_mainnet
from ..constants import NETWORKS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be imported from setup

raise ValueError('Unknown network type: {}'.format(network))

NETWORKS = {'mainnet': params,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params is never initialised if we don't get into the if on line 26

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.

3 participants