Removes chunks matching subscript byte-for-byte and returns a new script instance with subscript removed.
 So if pushdata items are encoded differently, they won't match.
 Consensus-critical code.
339259
def find_and_delete(subscript)
      subscript.is_a?(Script) or raise ArgumentError,"Argument must be an instance of BTC::Script"
      # Replacing [a b a]
      # Script: a b b a b a b a c
      # Result: a b b       b a c
      subscriptsize = subscript.chunks.size
      buf = []
      i = 0
      result = Script.new
      chunks.each do |chunk|
        if chunk == subscript.chunks[i]
          buf << chunk
          i+=1
          if i == subscriptsize # matched the whole subscript
            i = 0
            buf.clear
          end
        else
          i = 0
          result << buf
          result << chunk
        end
      end
      result
    end
857034
public void removePubSubOutputHandlerMatchTarget(
    ControllableProxySubscription sub)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "removePubSubOutputHandlerMatchTarget", sub);

    // Remove the PubSub OutputHandler from the matchspace
    try
    {
      removeTarget(sub);
    }
    catch (MatchingException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.matching.MessageProcessorMatching.removePubSubOutputHandlerMatchTarget",
        "1:1363:1.117.1.11",
        this);

      SibTr.exception(tc, e);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1370:1.117.1.11",
          e });

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "removePubSubOutputHandlerMatchTarget", "SICoreException");

      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1381:1.117.1.11",
            e },
          null),
        e);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "removePubSubOutputHandlerMatchTarget");
  }
173036
def cleanup_payload(self, payload):
        
        p = payload.replace('\n', '')
        p = p.rstrip()
        p = p.lstrip()
        return p
657125
function bytesToWords(input) {
  var i;
  var output = [];
  output[(input.length >> 2) - 1] = undefined;
  for (i = 0; i < output.length; i += 1) {
    output[i] = 0;
  }
  var length8 = input.length * 8;
  for (i = 0; i < length8; i += 8) {
    output[i >> 5] |= (input[(i / 8)] & 0xFF) << (i % 32);
  }

  return output;
}
876917
def btc_script_serialize(_script):
    
    script = _script
    if encoding.json_is_base(_script, 16):
        # hex-to-bin all hex strings in this script
        script = encoding.json_changebase(_script, lambda x: binascii.unhexlify(x))

    # encode each item and return the concatenated list
    return encoding.safe_hexlify( ''.join(map(_btc_script_serialize_unit, script)) )
875907
def from_bytes(cls, b):
		
		hdr = None
		head_chunks = []
		end = ("IEND", make_chunk("IEND", b""))
		
		frame_chunks = []
		frames = []
		num_plays = 0
		frame_has_head_chunks = False
		
		control = None
		
		for type_, data in parse_chunks(b):
			if type_ == "IHDR":
				hdr = data
				frame_chunks.append((type_, data))
			elif type_ == "acTL":
				_num_frames, num_plays = struct.unpack("!II", data[8:-4])
				continue
			elif type_ == "fcTL":
				if any(type_ == "IDAT" for type_, data in frame_chunks):
					# IDAT inside chunk, go to next frame
					frame_chunks.append(end)
					frames.append((PNG.from_chunks(frame_chunks), control))
					frame_has_head_chunks = False
					control = FrameControl.from_bytes(data[12:-4])
					# https://github.com/PyCQA/pylint/issues/2072
					# pylint: disable=typecheck
					hdr = make_chunk("IHDR", struct.pack("!II", control.width, control.height) + hdr[16:-4])
					frame_chunks = [("IHDR", hdr)]
				else:
					control = FrameControl.from_bytes(data[12:-4])
			elif type_ == "IDAT":
				if not frame_has_head_chunks:
					frame_chunks.extend(head_chunks)
					frame_has_head_chunks = True
				frame_chunks.append((type_, data))
			elif type_ == "fdAT":
				# convert to IDAT
				if not frame_has_head_chunks:
					frame_chunks.extend(head_chunks)
					frame_has_head_chunks = True
				frame_chunks.append(("IDAT", make_chunk("IDAT", data[12:-4])))
			elif type_ == "IEND":
				# end
				frame_chunks.append(end)
				frames.append((PNG.from_chunks(frame_chunks), control))
				break
			elif type_ in CHUNK_BEFORE_IDAT:
				head_chunks.append((type_, data))
			else:
				frame_chunks.append((type_, data))
				
		o = cls()
		o.frames = frames
		o.num_plays = num_plays
		return o
47133
def include?(item)
      chunk_item = if item.is_a?(Integer)
                     item.chr
                   elsif item.is_a?(String)
                     data = Encoding::ASCII_8BIT == item.encoding ? item : item.htb
                     Bitcoin::Script.pack_pushdata(data)
                   end
      return false unless chunk_item
      chunks.include?(chunk_item)
    end
136530
def append(object)
      if object.is_a?(BTC::Script)
        append_script(object)
      elsif object.is_a?(BTC::ScriptNumber)
        append_pushdata(object.data)
      elsif object.is_a?(Integer)
        append_opcode(object)
      elsif object.is_a?(String)
        append_pushdata(object.b)
      elsif object.is_a?(Array)
        object.each do |element|
          self << element
        end
      elsif object.is_a?(ScriptChunk)
        @chunks << object
      else
        raise ArgumentError, "Operand must be an integer, a string a BTC::Script instance or an array of any of those."
      end
      return self
    end
116971
private DiffPart decodeDelete(final int blockSize_S, final int blockSize_E)
		throws DecodingException
	{

		if (blockSize_S < 1 || blockSize_E < 1) {
			throw new DecodingException("Invalid value for blockSize_S: "
					+ blockSize_S + " or blockSize_E: " + blockSize_E);
		}

		int s = r.read(blockSize_S);
		int e = r.read(blockSize_E);

		DiffPart part = new DiffPart(DiffAction.DELETE);
		part.setStart(s);
		part.setLength(e);

		r.skip();

		return part;
	}
455388
def append_pushdata(data, opcode: nil)
      raise ArgumentError, "No data provided" if !data
      encoded_pushdata = self.class.encode_pushdata(data, opcode: opcode)
      if !encoded_pushdata
        raise ArgumentError, "Cannot encode pushdata with opcode #{opcode}"
      end
      @chunks << ScriptChunk.new(encoded_pushdata)
      return self
    end
1064483
function parseCodeChunkToAST(src, options) {
    src = src
    .replace(/@/g, '\uFFDA')
    .replace(/#/g, '\uFFDB')
    ;
    var ast = recast.parse(src);
    return ast;
}
215721
def btc_make_data_script( data, **ignored ):
    
    if len(data) >= MAX_DATA_LEN * 2:
        raise ValueError("Data hex string is too long")     # note: data is a hex string

    if len(data) % 2 != 0:
        raise ValueError("Data hex string is not even length")

    return "6a{:02x}{}".format(len(data)/2, data)
297784
def decompile_scriptPubKey(asm):
    
    asm = asm.split(" ")
    hex = ""
    if asm[0] == 'OP_DUP':
        hex += "76"
    if asm[1] == 'OP_HASH160':
        hex += 'a9'
    if len(asm[2]) == 40:
        hex += asm[2]
    if asm[3] == 'OP_EQUALVERIFY':
        hex += '88'
    if asm[4] == 'OP_CHECKSIG':
        hex += 'ac'
    return hex
1001377
public ByteArrayQueue remove(byte[] b, int off, int len) {
		System.arraycopy(array, offset, b, off, len);
		return remove(len);
	}
1369023
def btc_witness_script_deserialize(_script):
    

    script = None
    if isinstance(_script, str) and re.match('^[0-9a-fA-F]*$', _script):
        # convert from hex to bin, safely
        script = binascii.unhexlify(_script)
    else:
        script = _script[:]

    # pointer to byte offset in _script (as an array due to Python scoping rules)
    ptr = [0]

    witness_stack_len = read_var_int(ptr, script)
    witness_stack = []

    for _ in xrange(0, witness_stack_len):

        stack_item = read_var_string(ptr, script)
        witness_stack.append(stack_item)

    return witness_stack
355187
def remove(self, item):
        
        check_not_none(item, "item can't be none")
        return self._encode_invoke(transactional_set_remove_codec, item=self._to_data(item))
797099
def btc_script_hex_to_address( script_hex, segwit=None ):
    
    # TODO: make this support more than bitcoin-like scripts
    if script_hex.startswith("76a914") and script_hex.endswith("88ac") and len(script_hex) == 50:
        # p2pkh script
        hash160_bin = binascii.unhexlify(script_hex[6:-4])
        return bin_hash160_to_address(hash160_bin, version_byte=version_byte)

    elif script_hex.startswith("a914") and script_hex.endswith("87") and len(script_hex) == 46:
        # p2sh script
        hash160_bin = binascii.unhexlify(script_hex[4:-2])
        return bin_hash160_to_address(hash160_bin, version_byte=multisig_version_byte)

    elif script_hex.startswith('0014') and len(script_hex) == 44:
        # p2wpkh script (bech32 address)
        hash160_bin = binascii.unhexlify(script_hex[4:])
        return segwit_addr_encode(hash160_bin) 

    elif script_hex.startswith('0020') and len(script_hex) == 68:
        # p2wsh script (bech32 address)
        sha256_bin = binascii.unhexlify(script_hex[4:])
        return segwit_addr_encode(sha256_bin)

    return None