Example #1
0
 /**
  * @param int[]|\BitWasp\Bitcoin\Script\Interpreter\Number[]|BufferInterface[] $sequence
  * @return $this
  */
 public function sequence(array $sequence)
 {
     $new = new self($this->math, $this->opcodes, null);
     foreach ($sequence as $operation) {
         if (is_int($operation)) {
             if (!$this->opcodes->offsetExists($operation)) {
                 throw new \RuntimeException('Unknown opcode');
             }
             $new->script .= chr($operation);
         } elseif ($operation instanceof Number) {
             $new->push($operation->getBuffer());
         } elseif ($operation instanceof BufferInterface) {
             $new->push($operation);
         } else {
             throw new \RuntimeException('Input was neither an opcode or BufferInterfacecc');
         }
     }
     $this->concat($new->getScript());
     return $this;
 }