| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function getSigHash(ScriptInterface $script, int $sigHashType, int $sigVersion): BufferInterface |
||
| 33 | { |
||
| 34 | if ($sigVersion !== 0) { |
||
| 35 | throw new \RuntimeException("SigVersion must be 0"); |
||
| 36 | } |
||
| 37 | |||
| 38 | $cacheCheck = $sigHashType . $script->getBuffer()->getBinary(); |
||
| 39 | if (!isset($this->sigHashCache[$cacheCheck])) { |
||
| 40 | if ($sigHashType & SigHash::BITCOINCASH) { |
||
| 41 | $hasher = new V1Hasher($this->transaction, $this->amount); |
||
| 42 | } else { |
||
| 43 | $hasher = new Hasher($this->transaction); |
||
| 44 | } |
||
| 45 | |||
| 46 | $hash = $hasher->calculate($script, $this->nInput, $sigHashType); |
||
| 47 | $this->sigHashCache[$cacheCheck] = $hash->getBinary(); |
||
| 48 | } else { |
||
| 49 | $hash = new Buffer($this->sigHashCache[$cacheCheck], 32); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $hash; |
||
| 53 | } |
||
| 54 | } |
||
| 55 |