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