Returns number of bytes required to spend this script. It accepts optional ECKey and redeemScript that may
be required for certain types of script to estimate target size.
181259
public int getNumberOfBytesRequiredToSpend(@Nullable ECKey pubKey, @Nullable Script redeemScript) {
        if (ScriptPattern.isP2SH(this)) {
            // scriptSig: <sig> [sig] [sig...] <redeemscript>
            checkArgument(redeemScript != null, "P2SH script requires redeemScript to be spent");
            return redeemScript.getNumberOfSignaturesRequiredToSpend() * SIG_SIZE + redeemScript.getProgram().length;
        } else if (ScriptPattern.isSentToMultisig(this)) {
            // scriptSig: OP_0 <sig> [sig] [sig...]
            return getNumberOfSignaturesRequiredToSpend() * SIG_SIZE + 1;
        } else if (ScriptPattern.isP2PK(this)) {
            // scriptSig: <sig>
            return SIG_SIZE;
        } else if (ScriptPattern.isP2PKH(this)) {
            // scriptSig: <sig> <pubkey>
            int uncompressedPubKeySize = 65; // very conservative
            return SIG_SIZE + (pubKey != null ? pubKey.getPubKey().length : uncompressedPubKeySize);
        } else if (ScriptPattern.isP2WPKH(this)) {
            // scriptSig is empty
            // witness: <sig> <pubKey>
            int compressedPubKeySize = 33;
            return SIG_SIZE + (pubKey != null ? pubKey.getPubKey().length : compressedPubKeySize);
        } else {
            throw new IllegalStateException("Unsupported script type");
        }
    }
337130
public Integer getKeySize() {
		
		if(keySize == null){
			
			switch (algorithm) {
			case DES:
				keySize = DEFAULT_DES_KEY_SIZE;
				break;

			default:
				keySize = DEFAULT_AES_KEY_SIZE;
				break;
			}
			
		}
		
		return keySize;
		
	}
1046231
def parse_issuance_p2sh_pointer(script_sig)
      script = Bitcoin::Script.new(script_sig).chunks.last
      redeem_script = Bitcoin::Script.new(script)
      return nil unless redeem_script.chunks[1] == Bitcoin::Script::OP_DROP
      asset_def = to_bytes(redeem_script.chunks[0].to_s.bth)[0..-1].map{|x|x.to_i(16).chr}.join
      asset_def && asset_def.start_with?('u=') ? asset_def : nil
    end
368506
def size(self):
        '''
            
        '''
        t = self._type
        if t.startswith('uint'):
            return int(t[len('uint'):])
        if t.startswith('int'):
            return int(t[len('int'):])
        if t == 'bool':
            return int(8)
        if t == 'address':
            return int(160)
        if t.startswith('bytes'):
            return int(t[len('bytes'):])
        return None
615114
def count_remaining
      count = @executables_inputs.values.map { |a| a.values.count { |p| not p.is_a?(RightScale::SecureDocument) } }
      return count.inject { |sum,x| sum + x } || 0
    end
161109
def recv(self, maxsize=None):
        '''
        
        '''
        if maxsize is None:
            maxsize = 1024
        elif maxsize < 1:
            maxsize = 1
        return self._recv(maxsize)
1318261
def VerifyScripts(verifiable):
        
        try:
            hashes = verifiable.GetScriptHashesForVerifying()
        except Exception as e:
            logger.debug("couldn't get script hashes %s " % e)
            return False

        if len(hashes) != len(verifiable.Scripts):
            logger.debug(f"hash - verification script length mismatch ({len(hashes)}/{len(verifiable.Scripts)})")
            return False

        blockchain = GetBlockchain()

        for i in range(0, len(hashes)):
            verification = verifiable.Scripts[i].VerificationScript

            if len(verification) == 0:
                sb = ScriptBuilder()
                sb.EmitAppCall(hashes[i].Data)
                verification = sb.ms.getvalue()
            else:
                verification_hash = Crypto.ToScriptHash(verification, unhex=False)
                if hashes[i] != verification_hash:
                    logger.debug(f"hash {hashes[i]} does not match verification hash {verification_hash}")
                    return False

            state_reader = GetStateReader()
            script_table = CachedScriptTable(DBCollection(blockchain._db, DBPrefix.ST_Contract, ContractState))

            engine = ApplicationEngine(TriggerType.Verification, verifiable, script_table, state_reader, Fixed8.Zero())
            engine.LoadScript(verification)
            invocation = verifiable.Scripts[i].InvocationScript
            engine.LoadScript(invocation)

            try:
                success = engine.Execute()
                state_reader.ExecutionCompleted(engine, success)
            except Exception as e:
                state_reader.ExecutionCompleted(engine, False, e)

            if engine.ResultStack.Count != 1 or not engine.ResultStack.Pop().GetBoolean():
                Helper.EmitServiceEvents(state_reader)
                if engine.ResultStack.Count > 0:
                    logger.debug(f"Result stack failure! Count: {engine.ResultStack.Count} bool value: {engine.ResultStack.Pop().GetBoolean()}")
                else:
                    logger.debug(f"Result stack failure! Count: {engine.ResultStack.Count}")
                return False

            Helper.EmitServiceEvents(state_reader)

        return True
371091
def check_sig(script_sig, pubkey, script_code, sig_version)
      return false if script_sig.empty?
      script_sig = script_sig.htb
      hash_type = script_sig[-1].unpack('C').first
      sig = script_sig[0..-2]
      sighash = tx.sighash_for_input(input_index, script_code, hash_type: hash_type,
                                     amount: amount, sig_version: sig_version)
      key_type = pubkey.start_with?('02') || pubkey.start_with?('03') ? Key::TYPES[:compressed] : Key::TYPES[:uncompressed]
      key = Key.new(pubkey: pubkey, key_type: key_type)
      key.verify(sig, sighash)
    end
1031620
def from_bytes(TxIn, byte_string):
        '''
        
        '''
        outpoint = Outpoint.from_bytes(byte_string[:36])

        script_sig_len = VarInt.from_bytes(byte_string[36:45])
        script_start = 36 + len(script_sig_len)
        script_end = script_start + script_sig_len.number
        script_sig = byte_string[script_start:script_end]

        sequence = byte_string[script_end:script_end + 4]
        if script_sig == b'':
            stack_script = b''
            redeem_script = b''
        else:
            stack_script, redeem_script = TxIn._parse_script_sig(script_sig)
        return TxIn(
            outpoint=outpoint,
            stack_script=stack_script,
            redeem_script=redeem_script,
            sequence=sequence)
344689
def Size(self):
        
        return s.uint32 + 12 + s.uint32 + s.uint32 + len(self.Payload)
911435
def swo_num_bytes(self):
        
        res = self._dll.JLINKARM_SWO_Control(enums.JLinkSWOCommands.GET_NUM_BYTES,
                                             0)
        if res < 0:
            raise errors.JLinkException(res)

        return res
122926
def calculate_size(name, entry_processor):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += calculate_size_data(entry_processor)
    return data_size
1327092
public int getNumberOfSignaturesRequiredToSpend() {
        if (ScriptPattern.isSentToMultisig(this)) {
            // for N of M CHECKMULTISIG script we will need N signatures to spend
            ScriptChunk nChunk = chunks.get(0);
            return Script.decodeFromOpN(nChunk.opcode);
        } else if (ScriptPattern.isP2PKH(this) || ScriptPattern.isP2PK(this)) {
            // P2PKH and P2PK require single sig
            return 1;
        } else if (ScriptPattern.isP2SH(this)) {
            throw new IllegalStateException("For P2SH number of signatures depends on redeem script");
        } else {
            throw new IllegalStateException("Unsupported script type");
        }
    }
676974
def key_size(self):
        
        if self.key_algorithm in {PubKeyAlgorithm.ECDSA, PubKeyAlgorithm.ECDH}:
            return self._key.keymaterial.oid
        return next(iter(self._key.keymaterial)).bit_length()
1369790
def sizeof(s):
    
    if hasattr(s, '_size_'):
        return s._size_

    elif isinstance(s, bytes):
        return len(s)

    raise ValueError(s)
1012103
function len(srcObj) {
      if (isObj(srcObj)) {
        return keys(srcObj).length;
      }
      else if (typeOf(srcObj, 'str', 'arr', 'fun') || get(srcObj, 'length', 'num')) {
        return srcObj.length;
      }
      else return -1;
    }
1316408
def script
      raise ArgumentError, "BTC::ScriptHashAddress: invalid data length (must be 20 bytes)" if self.data.bytesize != 20
      BTC::Script.new << OP_HASH160 << self.data << OP_EQUAL
    end