diff --git a/coinkit/privatekey.py b/coinkit/privatekey.py index 32ca007..2d5c538 100644 --- a/coinkit/privatekey.py +++ b/coinkit/privatekey.py @@ -27,9 +27,12 @@ class BitcoinPrivateKey(): def wif_version_byte(cls): return (cls._pubkeyhash_version_byte + 128) % 256 - def __init__(self, private_key=None): + def __init__(self, private_key=None, pubkeyhash_version_byte = 0, wif_version_byte=None): """ Takes in a private key/secret exponent. """ + self._pubkeyhash_version_byte = pubkeyhash_version_byte + self._wif_version_byte = wif_version_byte + if not private_key: secret_exponent = random_secret_exponent(self._curve.order) elif is_int(private_key): @@ -74,8 +77,12 @@ def to_hex(self): return binascii.hexlify(self.to_bin()) def to_wif(self): + if self._wif_version_byte is None: + wif_byte = self.wif_version_byte() + else: + wif_byte = self._wif_version_byte return b58check_encode(self.to_bin(), - version_byte=self.wif_version_byte()) + version_byte=wif_byte) def public_key(self): # lazily calculate and set the public key @@ -92,6 +99,10 @@ def passphrase(self): else: raise Exception(_errors["NOT_A_BRAIN_WALLET"]) +class CoinPrivateKey(BitcoinPrivateKey): + def __init__(self, private_key=None, pubkeyhash_version_byte=0, wif_version_byte=None): + BitcoinPrivateKey.__init__(self, private_key, pubkeyhash_version_byte, wif_version_byte) + class LitecoinPrivateKey(BitcoinPrivateKey): _pubkeyhash_version_byte = 48 diff --git a/coinkit/publickey.py b/coinkit/publickey.py index d680c4d..978c8d0 100644 --- a/coinkit/publickey.py +++ b/coinkit/publickey.py @@ -67,6 +67,10 @@ def address(self): """ The address is the hash160 in b58check format. """ return self._hash160.address() +class CoinPublicKey(BitcoinPublicKey): + def __init__(self, public_key, version_byte = 0): + BitcoinPublicKey.__init__(self, public_key, version_byte) + class LitecoinPublicKey(BitcoinPublicKey): _version_byte = 48