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