From 0c3fa75b52a09b8f3d03cfdf446991ca6ebd758e Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sat, 28 Jan 2012 16:31:49 -0500 Subject: [PATCH] moved base58 to only p2pool.bitcoin.data --- p2pool/bitcoin/data.py | 5 +++-- p2pool/util/pack.py | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/p2pool/bitcoin/data.py b/p2pool/bitcoin/data.py index 3c5cf6d..921dd72 100644 --- a/p2pool/bitcoin/data.py +++ b/p2pool/bitcoin/data.py @@ -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'] diff --git a/p2pool/util/pack.py b/p2pool/util/pack.py index 69cbc7e..bed3c3b 100644 --- a/p2pool/util/pack.py +++ b/p2pool/util/pack.py @@ -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()) -- 1.7.1