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
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
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.