chainside / btcpy

A Python3 SegWit-compliant library which provides tools to handle Bitcoin data structures in a simple fashion.
https://www.chainside.net
GNU Lesser General Public License v3.0
270 stars 73 forks source link

PrivateKey: simplify WIF decoding #7

Closed peerchemist closed 6 years ago

peerchemist commented 6 years ago

Simplification of WIF decoding code.

SimoneBronzini commented 6 years ago

That's a very good idea! However, I would like to add the notion of compressed/uncompressed pubkeys inside PrivateKey, to be used in case of pub(), so I am already in the process of refactoring that part.

peerchemist commented 6 years ago

WIFs usually use compressed pubkey by default.

peerchemist commented 6 years ago

@SimoneBronzini I think we should add to_wif method on PrivateKey class, to allow for exporting to WIF format. from_wif can be made to save wif prefix by setattr to PrivateKey - which can then be used to assemble it back to WIF.

peerchemist commented 6 years ago

Like here: https://github.com/PeerAssets/pypeerassets/blob/master/pypeerassets/kutil.py#L73

SimoneBronzini commented 6 years ago

I completely agree, will work on this as soon as possible.