Get a list of script hashes for verifying transactions.

        Raises:
            Exception: if there are no valid assets in the transaction.

        Returns:
            list: of UInt160 type script hashes.
506386
def GetScriptHashesForVerifying(self):
        
        if not self.References and len(self.Attributes) < 1:
            return []

        hashes = set()
        for coinref, output in self.References.items():
            hashes.add(output.ScriptHash)

        for attr in self.Attributes:
            if attr.Usage == TransactionAttributeUsage.Script:
                if type(attr.Data) is UInt160:
                    hashes.add(attr.Data)
                else:
                    hashes.add(UInt160(data=attr.Data))

        for key, group in groupby(self.outputs, lambda p: p.AssetId):
            if self.raw_tx:
                asset = Helper.StaticAssetState(key)
            else:
                asset = GetBlockchain().GetAssetState(key.ToBytes())
            if asset is None:
                raise Exception("Invalid operation")

            if asset.AssetType == AssetType.DutyFlag:
                for p in group:
                    hashes.add(p.ScriptHash)

        hashlist = list(hashes)
        hashlist.sort()
        return hashlist
231960
def get_hashes(self, all_hashes = False):
		
		hashes = []
		for cred in self.credentials:
			res = Ticket.load(cred.ticket.to_asn1()).native
			if int(res['enc-part']['etype']) == 23 or all_hashes == True:
				hashes.append(cred.to_hash())

		return hashes
537733
def load_scripts():
    ''''''
    # Add scrypture package package to the path before importing
    # so everything can import everything else regardless of package
    scrypture_dir = os.path.realpath(
                         os.path.abspath(
                           os.path.split(
                             inspect.getfile( inspect.currentframe() ))[0]))

    if scrypture_dir not in sys.path:
        sys.path.insert(0, scrypture_dir)

    # Load list of registered scripts
    registered_scripts = app.config['REGISTERED_SCRIPTS']

    for script in registered_scripts:
        try:
            s = import_module('.'+script,
                package=os.path.split(app.config['SCRIPTS_DIR'])[-1])
            s.package = s.__name__.split('.')[1]
            #remove package from script name:
            script_name = script.split('.')[-1]
            registered_modules[script_name] = s
        except Exception as e:
            logging.warning('Could not import ' + \
                            str(script)+': '+str(e.message))
            logging.debug(str(traceback.format_exc()))
            continue
56448
def list_assets_ddo(self):
        
        return json.loads(self.requests_session.get(self.url).content)
869452
def GetTransactionResults(self):
        
        if self.References is None:
            return None

        results = []
        realresults = []
        for ref_output in self.References.values():
            results.append(TransactionResult(ref_output.AssetId, ref_output.Value))

        for output in self.outputs:
            results.append(TransactionResult(output.AssetId, output.Value * Fixed8(-1)))

        for key, group in groupby(results, lambda x: x.AssetId):
            sum = Fixed8(0)
            for item in group:
                sum = sum + item.Amount

            if sum != Fixed8.Zero():
                realresults.append(TransactionResult(key, sum))

        return realresults
597788
def get_block_transaction_hashes(self, block_header: BlockHeader) -> Iterable[Hash32]:
        
        return self._get_block_transaction_hashes(self.db, block_header)
75733
def get_asset_ddos():
    
    args = []
    query = dict()
    args.append(query)
    assets_with_id = dao.get_all_listed_assets()
    assets_metadata = {a['id']: a for a in assets_with_id}
    for i in assets_metadata:
        _sanitize_record(i)
    return Response(json.dumps(assets_metadata, default=_my_converter), 200,
                    content_type='application/json')
216816
def ScriptHash(self):
        
        if self._scriptHash is None:
            self._scriptHash = Crypto.ToScriptHash(self.Script, unhex=False)

        return self._scriptHash
410202
def _parse_script_sig(TxIn, script_sig):
        '''
        
        '''
        # Is there a better way to do this?
        stack_script = script_sig
        redeem_script = b''
        try:
            # If the last entry deserializes, it's a p2sh input
            # There is a vanishingly small edge case where the pubkey
            #   forms a deserializable script.
            # Edge case: serialization errors on CODESEPARATOR
            deserialized = serialization.deserialize(script_sig)
            items = deserialized.split()
            serialization.hex_deserialize(items[-1])
            stack_script = serialization.serialize(' '.join(items[:-1]))
            redeem_script = serialization.serialize(items[-1])
        except (IndexError, ValueError, NotImplementedError):
            pass

        return stack_script, redeem_script
235901
def parse_multisig_redeemscript( redeem_script_hex ):
    
    script_parts = []
    redeem_script_hex = str(redeem_script_hex)

    try:
        script_parts = btc_script_deserialize(redeem_script_hex)
    except:
        if os.environ.get("BLOCKSTACK_TEST") == "1":
            traceback.print_exc()

        log.error("Invalid redeem script %s" % redeem_script_hex)
        return None, None

    try:
        assert len(script_parts) > 2
        assert script_parts[-1] == OPCODE_VALUES['OP_CHECKMULTISIG']
        script_parts.pop(-1)

        # get n
        n = script_parts.pop(-1)
        pubkeys = []

        # get m
        m = script_parts.pop(0)

        for i in xrange(0, n):
            pubk = script_parts.pop(0)
            
            # must be a public key
            BitcoinPublicKey(pubk)
            pubkeys.append(pubk)

        assert len(script_parts) == 0, "script_parts = %s" % script_parts
        return (m, pubkeys)
    except Exception, e:
        if os.environ.get("BLOCKSTACK_TEST") == "1":
            traceback.print_exc()

        log.error("Invalid redeem script %s (parses to %s)" % (redeem_script_hex, script_parts))
        return (None, None)
250178
def list_assets(self):
        
        response = self.requests_session.get(self._base_url).content
        if not response:
            return {}

        try:
            asset_list = json.loads(response)
        except TypeError:
            asset_list = None
        except ValueError:
            raise ValueError(response.decode('UTF-8'))

        if not asset_list:
            return []

        if 'ids' in asset_list:
            return asset_list['ids']
        return []
570045
def verify_input_sig_for_witness(input_index, script_pubkey, amount, flags)
      flags |= SCRIPT_VERIFY_WITNESS
      flags |= SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
      checker = Bitcoin::TxChecker.new(tx: self, input_index: input_index, amount: amount)
      interpreter = Bitcoin::ScriptInterpreter.new(checker: checker, flags: flags)
      i = inputs[input_index]

      script_sig = i.script_sig
      witness = i.script_witness
      interpreter.verify_script(script_sig, script_pubkey, witness)
    end
1065737
def read_hashes(self):
        
        var_len = self.read_var_int()
        items = []
        for _ in range(0, var_len):
            ba = bytearray(self.read_bytes(32))
            ba.reverse()
            items.append(ba.hex())
        return items
105477
def __misphashtypes():
        
        hashtypes = ['md5', 'sha1', 'sha256', 'ssdeep', 'sha224', 'sha384', 'sha512', 'sha512/224', 'sha512/256',
                     'tlsh', 'authentihash']
        filenames = []
        for h in hashtypes:
            filenames.append('filename|{0}'.format(h))
        return hashtypes + filenames
189443
def eth_getTransactionByBlockHashAndIndex(self, bhash, index=0):
        
        result = yield from self.rpc_call('eth_getTransactionByBlockHashAndIndex',
                                          [bhash, hex(index)])
        # TODO: Update result response
        return result
342054
def altcore_data(self):
        
        ret = []
        for symbol in self.supported_currencies(project='altcore', level="address"):
            data = crypto_data[symbol]
            priv = data.get('private_key_prefix')
            pub = data.get('address_version_byte')
            hha = data.get('header_hash_algo')
            shb = data.get('script_hash_byte')

            supported = collections.OrderedDict()
            supported['name'] = data['name']
            supported['alias'] = symbol

            if pub is not None:
                supported['pubkeyhash'] = int(pub)
            if priv:
                supported['privatekey'] = priv
            supported['scripthash'] = shb if shb else 5
            if 'transaction_form' in data:
                supported['transactionForm'] = data['transaction_form']
            if 'private_key_form' in data:
                supported['privateKeyForm'] = data['private_key_form']
            #if 'message_magic' in data and data['message_magic']:
            #    supported['networkMagic'] = '0x%s' % binascii.hexlify(data['message_magic'])
            supported['port'] = data.get('port') or None
            if hha not in (None, 'double-sha256'):
                supported['headerHashAlgo'] = hha
            if data.get('script_hash_algo', 'double-sha256') not in (None, 'double-sha256'):
                supported['scriptHashAlgo'] = data['script_hash_algo']
            if data.get('transaction_hash_algo', 'double-sha256') not in (None, 'double-sha256'):
                supported['transactionHashAlgo'] = data['transaction_hash_algo']
            if data.get('seed_nodes'):
                supported['dnsSeeds'] = data['seed_nodes']

            ret.append(supported)

        return ret
997710
def get_banks(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.BankList(self._results, runtime=self._runtime)