@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | rewind($stream); |
| 55 | 55 | |
| 56 | 56 | return $segwit ? |
| 57 | - self::parseSegWit($stream, $mode) : |
|
| 58 | - self::parseLegacy($stream, $mode); |
|
| 57 | + self::parseSegWit($stream, $mode) : self::parseLegacy($stream, $mode); |
|
| 59 | 58 | } |
| 60 | 59 | |
| 61 | 60 | public function serialize(): string |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | $witness .= Encoding\VarInt::encode(\count($txIn->witness)); |
| 75 | 74 | foreach ($txIn->witness as $element) { |
| 76 | 75 | $witness .= \is_int($element) ? |
| 77 | - Encoding\Endian::toLE(gmp_init($element)) : |
|
| 78 | - Encoding\VarInt::encode(\strlen($element)).$element; |
|
| 76 | + Encoding\Endian::toLE(gmp_init($element)) : Encoding\VarInt::encode(\strlen($element)).$element; |
|
| 79 | 77 | } |
| 80 | 78 | } |
| 81 | 79 | } |
@@ -97,12 +95,12 @@ discard block |
||
| 97 | 95 | |
| 98 | 96 | public function isCoinbase(): bool |
| 99 | 97 | { |
| 100 | - return 1 === \count($this->txIns) |
|
| 98 | + return 1 === \count($this->txIns) |
|
| 101 | 99 | && '0000000000000000000000000000000000000000000000000000000000000000' === $this->txIns[0]->prevTxId |
| 102 | - && 0xFFFFFFFF === $this->txIns[0]->prevIndex; |
|
| 100 | + && 0xFFFFFFFF === $this->txIns[0]->prevIndex; |
|
| 103 | 101 | } |
| 104 | 102 | |
| 105 | - public function blockHeight(): int|false |
|
| 103 | + public function blockHeight(): int | false |
|
| 106 | 104 | { |
| 107 | 105 | if (!$this->isCoinbase()) { |
| 108 | 106 | return false; |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | $acc = 0; |
| 115 | 115 | $bits = 0; |
| 116 | 116 | $ret = []; |
| 117 | - $maxv = (1 << $toBits) - 1; |
|
| 117 | + $maxv = (1 << $toBits) - 1; |
|
| 118 | 118 | $maxAcc = (1 << ($fromBits + $toBits - 1)) - 1; |
| 119 | 119 | |
| 120 | 120 | foreach ($data as $value) { |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private static function payToScriptHashSequence(array $cmds): bool |
| 102 | 102 | { |
| 103 | - return 3 === \count($cmds) |
|
| 103 | + return 3 === \count($cmds) |
|
| 104 | 104 | && $cmds[0] === OpCodes::OP_HASH160->value |
| 105 | 105 | && \is_string($cmds[1]) |
| 106 | - && 20 === \strlen($cmds[1]) |
|
| 106 | + && 20 === \strlen($cmds[1]) |
|
| 107 | 107 | && $cmds[2] === OpCodes::OP_EQUAL->value; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | private static function payToWitnessPubKeyHashSequence(array $stack): bool |
| 141 | 141 | { |
| 142 | - return 2 === \count($stack) |
|
| 142 | + return 2 === \count($stack) |
|
| 143 | 143 | && $stack[0] === Encoding\StackNum::encode(0) |
| 144 | 144 | && \is_string($stack[1]) |
| 145 | 145 | && 20 === \strlen($stack[1]); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | private static function payToWitnessScriptHashSequence(array $stack): bool |
| 149 | 149 | { |
| 150 | - return 2 === \count($stack) |
|
| 150 | + return 2 === \count($stack) |
|
| 151 | 151 | && $stack[0] === Encoding\StackNum::encode(0) |
| 152 | 152 | && \is_string($stack[1]) |
| 153 | 153 | && 32 === \strlen($stack[1]); |