moved base58 to only p2pool.bitcoin.data
authorForrest Voight <forrest.voight@gmail.com>
Sat, 28 Jan 2012 21:31:49 +0000 (16:31 -0500)
committerForrest Voight <forrest@forre.st>
Sat, 28 Jan 2012 23:58:52 +0000 (18:58 -0500)
p2pool/bitcoin/data.py
p2pool/util/pack.py

index 3c5cf6d..921dd72 100644 (file)
@@ -3,6 +3,7 @@ from __future__ import division
 import hashlib
 
 from p2pool.util import bases, math, pack
+from . import base58
 
 class ChecksummedType(pack.Type):
     def __init__(self, inner):
@@ -191,13 +192,13 @@ human_address_type = ChecksummedType(pack.ComposedType([
 pubkey_type = pack.PassthruType()
 
 def pubkey_hash_to_address(pubkey_hash, net):
-    return human_address_type.pack_base58(dict(version=net.ADDRESS_VERSION, pubkey_hash=pubkey_hash))
+    return base58.encode(human_address_type.pack(dict(version=net.ADDRESS_VERSION, pubkey_hash=pubkey_hash)))
 
 def pubkey_to_address(pubkey, net):
     return pubkey_hash_to_address(pubkey_type.hash160(pubkey), net)
 
 def address_to_pubkey_hash(address, net):
-    x = human_address_type.unpack_base58(address)
+    x = human_address_type.unpack(base58.decode(address))
     if x['version'] != net.ADDRESS_VERSION:
         raise ValueError('address not for this net!')
     return x['pubkey_hash']
index 69cbc7e..bed3c3b 100644 (file)
@@ -2,7 +2,6 @@ import binascii
 import hashlib
 import struct
 
-from p2pool.bitcoin import base58
 import p2pool
 
 class EarlyEnd(Exception):
@@ -83,13 +82,6 @@ class Type(object):
         return data
     
     
-    def pack_base58(self, obj):
-        return base58.encode(self.pack(obj))
-    
-    def unpack_base58(self, base58_data):
-        return self.unpack(base58.decode(base58_data))
-    
-    
     def hash160(self, obj):
         return IntType(160).unpack(hashlib.new('ripemd160', hashlib.sha256(self.pack(obj)).digest()).digest())