/** * @param EcAdapterInterface $ecAdapter * @param ScriptInterface $outputScript * @param ScriptInterface $redeemScript */ public function __construct(EcAdapterInterface $ecAdapter, ScriptInterface $outputScript, ScriptInterface $redeemScript = null) { /* $classifier = new OutputClassifier($outputScript); $this->scriptType = $this->prevOutType = $classifier->classify(); // Get the handler for this script type, and reclassify p2sh if ($this->scriptType === OutputClassifier::PAYTOSCRIPTHASH) { if (null === $redeemScript) { throw new \InvalidArgumentException('Redeem script is required when output is P2SH'); } $handler = new ScriptHash($redeemScript); $this->scriptType = $handler->classification(); } else { $handler = ScriptFactory::info($outputScript); } */ $handler = ScriptFactory::info($outputScript, $redeemScript); $this->scriptType = $this->prevOutType = $handler->classification(); if ($handler instanceof ScriptHash) { $this->scriptType = $handler->getInfo()->classification(); } // Gather public keys from redeemScript / outputScript $this->ecAdapter = $ecAdapter; $this->redeemScript = $redeemScript; $this->prevOutScript = $outputScript; $this->scriptInfo = $handler; // According to scriptType, extract public keys $this->publicKeys = $this->scriptInfo->getKeys(); }
/** * TxSignerContext constructor. * @param EcAdapterInterface $ecAdapter * @param ScriptInterface $outputScript * @param ScriptInterface|null $redeemScript */ public function __construct(EcAdapterInterface $ecAdapter, ScriptInterface $outputScript, ScriptInterface $redeemScript = null) { $handler = ScriptFactory::info($outputScript, $redeemScript); $handler->getKeys(); $this->scriptType = $this->prevOutType = $handler->classification(); if ($handler instanceof ScriptHash) { $this->scriptType = $handler->getInfo()->classification(); } // Gather public keys from redeemScript / outputScript $this->ecAdapter = $ecAdapter; $this->redeemScript = $redeemScript; $this->prevOutScript = $outputScript; $this->scriptInfo = $handler; // According to scriptType, extract public keys $this->publicKeys = $this->scriptInfo->getKeys(); }