Пример #1
0
 /**
  * @param int|string $m
  * @param \BitWasp\Bitcoin\Key\PublicKeyInterface[] $keys
  */
 public function __construct($m, array $keys)
 {
     parent::__construct();
     $n = count($keys);
     if ($m > $n) {
         throw new \LogicException('Required number of sigs exceeds number of public keys');
     }
     if ($n > 16) {
         throw new \LogicException('Number of public keys is greater than 16');
     }
     $ops = $this->getOpCodes();
     $opM = $ops->getOp($ops->getOpByName('OP_1') - 1 + $m);
     $opN = $ops->getOp($ops->getOpByName('OP_1') - 1 + $n);
     $this->op($opM);
     foreach ($keys as $key) {
         if (!$key instanceof PublicKeyInterface) {
             throw new \LogicException('Values in $keys[] must be a PublicKey');
         }
         $this->keys[] = $key;
         $this->push($key->getBuffer());
     }
     $this->op($opN)->op('OP_CHECKMULTISIG');
     $this->m = $m;
 }
Пример #2
0
 /**
  * P2shScript constructor.
  * @param ScriptInterface $script
  * @param Opcodes|null $opcodes
  */
 public function __construct(ScriptInterface $script, Opcodes $opcodes = null)
 {
     parent::__construct($script->getBuffer(), $opcodes);
     $this->outputScript = ScriptFactory::scriptPubKey()->payToScriptHash($script);
 }