Completed
Push — master ( 15714e...2fb532 )
by Marcel
01:08
created
src/Tx/Script.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 
137 137
     public function isP2SH(): bool
138 138
     {
139
-        return 3              === \count($this->cmds)
139
+        return 3 === \count($this->cmds)
140 140
             && $this->cmds[0] === OpCodes::OP_HASH160->value
141 141
             && \is_string($this->cmds[1])
142
-            && 20             === \strlen($this->cmds[1])
142
+            && 20 === \strlen($this->cmds[1])
143 143
             && $this->cmds[2] === OpCodes::OP_EQUAL->value;
144 144
     }
145 145
 
146 146
     public function isP2WPKH(): bool
147 147
     {
148
-        return 2              === \count($this->cmds)
148
+        return 2 === \count($this->cmds)
149 149
             && $this->cmds[0] === OpCodes::OP_0->value
150 150
             && \is_string($this->cmds[1])
151 151
             && 20 === \strlen($this->cmds[1]);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
     public function isP2WSH(): bool
155 155
     {
156
-        return 2              === \count($this->cmds)
156
+        return 2 === \count($this->cmds)
157 157
             && $this->cmds[0] === OpCodes::OP_0->value
158 158
             && \is_string($this->cmds[1])
159 159
             && 32 === \strlen($this->cmds[1]);
Please login to merge, or discard this patch.
src/ECC/S256Field.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 {
12 12
     public \GMP $num;
13 13
 
14
-    public function __construct(\GMP|int|string $number)
14
+    public function __construct(\GMP | int | string $number)
15 15
     {
16 16
         if (\is_int($number)) {
17 17
             $number = gmp_init($number);
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
         if (\is_string($number)) {
21 21
             $number = str_starts_with($number, '0x') ?
22
-                gmp_init($number) :
23
-                gmp_import($number);
22
+                gmp_init($number) : gmp_import($number);
24 23
         }
25 24
 
26 25
         if ($number < 0 || S256Params::P() <= $number) {
@@ -50,7 +49,7 @@  discard block
 block discarded – undo
50 49
         return new self(($this->num * gmp_powm($divisor->num, S256Params::P() - 2, S256Params::P())) % S256Params::P());
51 50
     }
52 51
 
53
-    public function exp(\GMP|int $exponent): self
52
+    public function exp(\GMP | int $exponent): self
54 53
     {
55 54
         return new self(gmp_powm($this->num, $exponent % (S256Params::P() - 1), S256Params::P()));
56 55
     }
Please login to merge, or discard this patch.
src/HDW/DerivationPath.php 1 patch
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
         foreach ($this->levels as $level) {
52 52
             [$key, $chainCode] = $key instanceof PrivateKey ?
53
-                CKDFunctions::CKDPriv($key, $chainCode, $level) :
54
-                CKDFunctions::CKDPub($key, $chainCode, $level);
53
+                CKDFunctions::CKDPriv($key, $chainCode, $level) : CKDFunctions::CKDPub($key, $chainCode, $level);
55 54
 
56 55
             $extendedKey = new ExtendedKey(
57 56
                 $extendedKey->version,
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
         $keys = [];
79 78
         for ($i = $offset; $i < $offset + $limit; ++$i) {
80 79
             $keys[] = $extendedKey->key instanceof PrivateKey ?
81
-                CKDFunctions::CKDPriv($extendedKey->key, $extendedKey->chainCode, $i)[0] :
82
-                CKDFunctions::CKDPub($extendedKey->key, $extendedKey->chainCode, $i)[0];
80
+                CKDFunctions::CKDPriv($extendedKey->key, $extendedKey->chainCode, $i)[0] : CKDFunctions::CKDPub($extendedKey->key, $extendedKey->chainCode, $i)[0];
83 81
         }
84 82
 
85 83
         return $keys;
Please login to merge, or discard this patch.
src/Tx.php 1 patch
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Encoding/Bech32.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Tx/Script/Interpreter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]);
Please login to merge, or discard this patch.
src/ECC/PublicKey.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,15 +66,14 @@  discard block
 block discarded – undo
66 66
         }
67 67
 
68 68
         $lam = $this->equals($other) ?
69
-            new S256Field(3)->mul($this->x->exp(2))->mul(new S256Field(2)->mul($this->y)->exp(S256Params::P() - 2)) :
70
-            $other->y->sub($this->y)->mul($other->x->sub($this->x)->exp(S256Params::P() - 2));
69
+            new S256Field(3)->mul($this->x->exp(2))->mul(new S256Field(2)->mul($this->y)->exp(S256Params::P() - 2)) : $other->y->sub($this->y)->mul($other->x->sub($this->x)->exp(S256Params::P() - 2));
71 70
 
72 71
         $x3 = $lam->mul($lam)->sub($this->x)->sub($other->x);
73 72
 
74 73
         return new self($x3, $this->x->sub($x3)->mul($lam)->sub($this->y));
75 74
     }
76 75
 
77
-    public function scalarMul(\GMP|int $coefficient): self
76
+    public function scalarMul(\GMP | int $coefficient): self
78 77
     {
79 78
         // Optimization: reduce the coefficient modulo N before computing the multiplication
80 79
         $c       = $coefficient % S256Params::N();
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
         $beta  = $alpha->sqrt();
131 130
 
132 131
         return "\x02" === $sec[0] ?
133
-            new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) :
134
-            new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta);
132
+            new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) : new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta);
135 133
     }
136 134
 
137 135
     public function sec(bool $compressed = true): string
@@ -157,7 +155,7 @@  discard block
 block discarded – undo
157 155
     {
158 156
         $sInv = gmp_powm($sig->s, S256Params::N() - 2, S256Params::N());
159 157
 
160
-        $u = ($z * $sInv)      % S256Params::N();
158
+        $u = ($z * $sInv) % S256Params::N();
161 159
         $v = ($sig->r * $sInv) % S256Params::N();
162 160
 
163 161
         $R = S256Params::G()->scalarMul($u)->add($this->scalarMul($v));
Please login to merge, or discard this patch.
src/HDW/ExtendedKey.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
     public string $parentFingerprint;
23 23
     public int $childNumber;
24 24
     public string $chainCode;
25
-    public PrivateKey|PublicKey $key;
25
+    public PrivateKey | PublicKey $key;
26 26
 
27
-    public function __construct(Version $version, int $depth, string $parentFingerprint, int $childNumber, string $chainCode, PrivateKey|PublicKey $key)
27
+    public function __construct(Version $version, int $depth, string $parentFingerprint, int $childNumber, string $chainCode, PrivateKey | PublicKey $key)
28 28
     {
29 29
         if (0 === $depth && self::MASTER_FINGERPRINT !== $parentFingerprint) {
30 30
             throw new \InvalidArgumentException('An extended key of depth 0 cannot have a parent fingerprint');
Please login to merge, or discard this patch.