def _script_to_hash(self, script): """Converts a script to it's hash equivalent Uses a segwit's python reference implementation for now. (TODO) """ script_bytes = script.to_bytes() hashsha256 = hashlib.sha256(script_bytes).digest() return hexlify(hashsha256).decode('utf-8')
def _script_to_hash160(self, script): """Converts a script to it's hash160 equivalent RIPEMD160( SHA256( script ) ) - required for P2SH addresses """ script_bytes = script.to_bytes() hashsha256 = hashlib.sha256(script_bytes).digest() hashripemd160 = hashlib.new('ripemd160') hashripemd160.update(hashsha256) hash160 = hashripemd160.digest() return hexlify(hash160).decode('utf-8')
def _script_to_hash(self, script): """Converts a script to it's hash equivalent""" script_bytes = script.to_bytes() hashsha256 = hashlib.sha256(script_bytes).digest() return hexlify(hashsha256).decode('utf-8')