Remove several unused functions

This commit is contained in:
Andrew Chow 2019-02-04 17:47:35 -05:00
parent 6349dd149c
commit a1b36e2121
3 changed files with 1 additions and 67 deletions

View File

@ -87,18 +87,6 @@ def to_address(b, version):
data += checksum
return encode(data)
def pubkey_to_address(pubkey, testnet=False):
pkh = hash160(pubkey)
if testnet:
return to_address(pkh, b'\x6f')
else:
return to_address(pkh, b'\x00')
def xpub_to_address(xpub, testnet=False):
data = decode(xpub)
pubkey = data[-37:-4]
return pubkey_to_address(pubkey, testnet)
def xpub_to_pub_hex(xpub):
data = decode(xpub)
pubkey = data[-37:-4]

View File

@ -6,7 +6,7 @@ import glob
import importlib
from .serializations import PSBT, Base64ToHex, HexToBase64, hash160
from .base58 import xpub_to_address, xpub_to_pub_hex, get_xpub_fingerprint_as_id, get_xpub_fingerprint_hex
from .base58 import get_xpub_fingerprint_as_id, get_xpub_fingerprint_hex
from os.path import dirname, basename, isfile
from .errors import NoPasswordError, UnavailableActionError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, UnknownDeviceError, BAD_ARGUMENT, NOT_IMPLEMENTED

View File

@ -91,12 +91,6 @@ def uint256_from_str(s):
return r
def uint256_from_compact(c):
nbytes = (c >> 24) & 0xFF
v = (c & 0xFFFFFF) << (8 * (nbytes - 3))
return v
def deser_vector(f, c):
nit = deser_compact_size(f)
r = []
@ -120,22 +114,6 @@ def ser_vector(l, ser_function_name=None):
return r
def deser_uint256_vector(f):
nit = deser_compact_size(f)
r = []
for i in range(nit):
t = deser_uint256(f)
r.append(t)
return r
def ser_uint256_vector(l):
r = ser_compact_size(len(l))
for i in l:
r += ser_uint256(i)
return r
def deser_string_vector(f):
nit = deser_compact_size(f)
r = []
@ -151,31 +129,6 @@ def ser_string_vector(l):
r += ser_string(sv)
return r
def deser_int_vector(f):
nit = deser_compact_size(f)
r = []
for i in range(nit):
t = struct.unpack("<i", f.read(4))[0]
r.append(t)
return r
def ser_int_vector(l):
r = ser_compact_size(len(l))
for i in l:
r += struct.pack("<i", i)
return r
# Deserialize from a hex string representation (eg from RPC)
def FromHex(obj, hex_string):
obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
return obj
# Convert a binary-serializable object to hex (eg for submission via RPC)
def ToHex(obj):
return bytes_to_hex_str(obj.serialize())
def Base64ToHex(s):
return binascii.hexlify(base64.b64decode(s))
@ -478,13 +431,6 @@ class CTransaction(object):
self.sha256 = uint256_from_str(hash256(self.serialize_without_witness()))
self.hash = encode(hash256(self.serialize())[::-1], 'hex_codec').decode('ascii')
def is_valid(self):
self.calc_sha256()
for tout in self.vout:
if tout.nValue < 0 or tout.nValue > 21000000 * COIN:
return False
return True
def is_null(self):
return len(self.vin) == 0 and len(self.vout) == 0