| 1 | <?php |
||
| 9 | class PayToPubkeyHash |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var BufferInterface |
||
| 14 | */ |
||
| 15 | private $hash; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param ScriptInterface $script |
||
| 19 | */ |
||
| 20 | 2 | public function __construct(ScriptInterface $script) |
|
| 21 | { |
||
| 22 | 2 | $chunks = $script->getScriptParser()->decode(); |
|
| 23 | 2 | if (count($chunks) !== 5 || !$chunks[2]->isPush() || !$chunks[2]->getData() === 20) { |
|
| 24 | throw new \RuntimeException('Malformed pay-to-pubkey-hash script'); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** @var BufferInterface $hash */ |
||
| 28 | 2 | $hash = $chunks[2]->getData(); |
|
| 29 | 2 | $this->hash = $hash; |
|
| 30 | 2 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @return int |
||
| 34 | */ |
||
| 35 | 2 | public function getRequiredSigCount() |
|
| 36 | { |
||
| 37 | 2 | return 1; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return int |
||
| 42 | */ |
||
| 43 | 2 | public function getKeyCount() |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @param PublicKeyInterface $publicKey |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | 2 | public function checkInvolvesKey(PublicKeyInterface $publicKey) |
|
| 56 | |||
| 57 | /** |
||
| 58 | * @return BufferInterface |
||
| 59 | */ |
||
| 60 | public function getPubKeyHash() |
||
| 64 | } |
||
| 65 |