1 | <?php |
||
25 | class Checker |
||
26 | { |
||
27 | /** |
||
28 | * @var EcAdapterInterface |
||
29 | */ |
||
30 | protected $adapter; |
||
31 | |||
32 | /** |
||
33 | * @var TransactionInterface |
||
34 | */ |
||
35 | protected $transaction; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $nInput; |
||
41 | |||
42 | /** |
||
43 | * @var int|string |
||
44 | */ |
||
45 | protected $amount; |
||
46 | |||
47 | /** |
||
48 | * @var Hasher |
||
49 | */ |
||
50 | protected $hasherV0; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $sigHashCache = []; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | protected $sigCache = []; |
||
61 | |||
62 | /** |
||
63 | * @var TransactionSignatureSerializer |
||
64 | */ |
||
65 | private $sigSerializer; |
||
66 | |||
67 | /** |
||
68 | * @var PublicKeySerializerInterface |
||
69 | */ |
||
70 | private $pubKeySerializer; |
||
71 | |||
72 | /** |
||
73 | * @var int |
||
74 | */ |
||
75 | protected $sigHashOptionalBits = SigHash::ANYONECANPAY; |
||
76 | |||
77 | /** |
||
78 | * Checker constructor. |
||
79 | * @param EcAdapterInterface $ecAdapter |
||
80 | * @param TransactionInterface $transaction |
||
81 | * @param int $nInput |
||
82 | * @param int $amount |
||
83 | * @param TransactionSignatureSerializer|null $sigSerializer |
||
84 | * @param PublicKeySerializerInterface|null $pubKeySerializer |
||
85 | */ |
||
86 | 2466 | public function __construct(EcAdapterInterface $ecAdapter, TransactionInterface $transaction, $nInput, $amount, TransactionSignatureSerializer $sigSerializer = null, PublicKeySerializerInterface $pubKeySerializer = null) |
|
95 | |||
96 | /** |
||
97 | * @param BufferInterface $signature |
||
98 | * @return bool |
||
99 | */ |
||
100 | 94 | public function isValidSignatureEncoding(BufferInterface $signature) |
|
111 | |||
112 | /** |
||
113 | * @param BufferInterface $signature |
||
114 | * @return bool |
||
115 | * @throws ScriptRuntimeException |
||
116 | * @throws \Exception |
||
117 | */ |
||
118 | 8 | public function isLowDerSignature(BufferInterface $signature) |
|
131 | |||
132 | /** |
||
133 | * @param int $hashType |
||
134 | * @return bool |
||
135 | */ |
||
136 | 80 | public function isDefinedHashtype($hashType) |
|
137 | { |
||
138 | 80 | $nHashType = $hashType & (~($this->sigHashOptionalBits)); |
|
139 | |||
140 | 80 | return !(($nHashType < SigHash::ALL) || ($nHashType > SigHash::SINGLE)); |
|
141 | } |
||
142 | |||
143 | /** |
||
144 | * Determine whether the sighash byte appended to the signature encodes |
||
145 | * a valid sighash type. |
||
146 | * |
||
147 | * @param BufferInterface $signature |
||
148 | * @return bool |
||
149 | */ |
||
150 | 28 | public function isDefinedHashtypeSignature(BufferInterface $signature) |
|
159 | |||
160 | /** |
||
161 | * @param BufferInterface $signature |
||
162 | * @param int $flags |
||
163 | * @return $this |
||
164 | * @throws \BitWasp\Bitcoin\Exceptions\ScriptRuntimeException |
||
165 | */ |
||
166 | 312 | public function checkSignatureEncoding(BufferInterface $signature, $flags) |
|
182 | |||
183 | /** |
||
184 | * @param BufferInterface $publicKey |
||
185 | * @param int $flags |
||
186 | * @return $this |
||
187 | * @throws \Exception |
||
188 | */ |
||
189 | 252 | public function checkPublicKeyEncoding(BufferInterface $publicKey, $flags) |
|
197 | |||
198 | /** |
||
199 | * @param ScriptInterface $script |
||
200 | * @param int $sigHashType |
||
201 | * @param int $sigVersion |
||
202 | * @return BufferInterface |
||
203 | */ |
||
204 | 174 | public function getSigHash(ScriptInterface $script, $sigHashType, $sigVersion) |
|
226 | |||
227 | /** |
||
228 | * @param ScriptInterface $script |
||
229 | * @param BufferInterface $sigBuf |
||
230 | * @param BufferInterface $keyBuf |
||
231 | * @param int $sigVersion |
||
232 | * @param int $flags |
||
233 | * @return bool |
||
234 | * @throws ScriptRuntimeException |
||
235 | */ |
||
236 | 298 | public function checkSig(ScriptInterface $script, BufferInterface $sigBuf, BufferInterface $keyBuf, $sigVersion, $flags) |
|
259 | |||
260 | /** |
||
261 | * @param int $txLockTime |
||
262 | * @param int $nThreshold |
||
263 | * @param \BitWasp\Bitcoin\Script\Interpreter\Number $lockTime |
||
264 | * @return bool |
||
265 | */ |
||
266 | private function verifyLockTime($txLockTime, $nThreshold, \BitWasp\Bitcoin\Script\Interpreter\Number $lockTime) |
||
277 | |||
278 | /** |
||
279 | * @param \BitWasp\Bitcoin\Script\Interpreter\Number $lockTime |
||
280 | * @return bool |
||
281 | */ |
||
282 | public function checkLockTime(\BitWasp\Bitcoin\Script\Interpreter\Number $lockTime) |
||
290 | |||
291 | |||
292 | /** |
||
293 | * @param \BitWasp\Bitcoin\Script\Interpreter\Number $sequence |
||
294 | * @return bool |
||
295 | */ |
||
296 | 4 | public function checkSequence(\BitWasp\Bitcoin\Script\Interpreter\Number $sequence) |
|
314 | } |
||
315 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.