1 | <?php |
||
13 | class Network implements NetworkInterface |
||
14 | { |
||
15 | const BECH32_PREFIX_SEGWIT = "segwit"; |
||
16 | |||
17 | const BASE58_ADDRESS_P2PKH = "p2pkh"; |
||
18 | const BASE58_ADDRESS_P2SH = "p2sh"; |
||
19 | const BASE58_WIF = "wif"; |
||
20 | const BIP32_PREFIX_XPUB = "xpub"; |
||
21 | const BIP32_PREFIX_XPRV = "xprv"; |
||
22 | |||
23 | /** |
||
24 | * @var array map of base58 address type to byte |
||
25 | */ |
||
26 | protected $base58PrefixMap = []; |
||
27 | |||
28 | /** |
||
29 | * @var array map of bech32 address type to HRP |
||
30 | */ |
||
31 | protected $bech32PrefixMap = []; |
||
32 | |||
33 | /** |
||
34 | * @var array map of bip32 type to bytes |
||
35 | */ |
||
36 | protected $bip32PrefixMap = []; |
||
37 | |||
38 | /** |
||
39 | * @var array map of bip32 key type to script type |
||
40 | */ |
||
41 | protected $bip32ScriptTypeMap = []; |
||
42 | |||
43 | /** |
||
44 | * @var string - message prefix for bitcoin signed messages |
||
45 | */ |
||
46 | protected $signedMessagePrefix; |
||
47 | |||
48 | /** |
||
49 | * @var string - 4 bytes for p2p magic |
||
50 | */ |
||
51 | protected $p2pMagic; |
||
52 | |||
53 | /** |
||
54 | * @param string $field - name of field being validated |
||
55 | * @param string $value - we check this value |
||
56 | * @param int $length - length we require |
||
|
|||
57 | * @throws InvalidNetworkParameter |
||
58 | */ |
||
59 | 142 | private function validateHexStringRepresentsBytes(string $field, string $value) |
|
79 | |||
80 | 142 | /** |
|
81 | 142 | * Network constructor. |
|
82 | * @throws InvalidNetworkParameter |
||
83 | */ |
||
84 | 142 | public function __construct() |
|
102 | |||
103 | /** |
||
104 | * @param string $prefixType |
||
105 | * @return bool |
||
106 | */ |
||
107 | 77 | protected function hasBase58Prefix(string $prefixType): bool |
|
111 | |||
112 | 76 | /** |
|
113 | * @param string $prefixType |
||
114 | * @return string |
||
115 | * @throws MissingBase58Prefix |
||
116 | */ |
||
117 | protected function getBase58Prefix(string $prefixType): string |
||
124 | |||
125 | /** |
||
126 | * @param string $prefixType |
||
127 | * @return bool |
||
128 | */ |
||
129 | 40 | protected function hasBech32Prefix(string $prefixType): bool |
|
133 | |||
134 | 39 | /** |
|
135 | * @param string $prefixType |
||
136 | * @return string |
||
137 | * @throws MissingBech32Prefix |
||
138 | */ |
||
139 | protected function getBech32Prefix(string $prefixType): string |
||
146 | |||
147 | /** |
||
148 | * @param string $prefixType |
||
149 | * @return bool |
||
150 | */ |
||
151 | 63 | protected function hasBip32Prefix(string $prefixType): bool |
|
155 | |||
156 | 62 | /** |
|
157 | * @param string $prefixType |
||
158 | * @return string |
||
159 | * @throws MissingBip32Prefix |
||
160 | */ |
||
161 | protected function getBip32Prefix(string $prefixType): string |
||
168 | |||
169 | 22 | /** |
|
170 | * @return string |
||
171 | * @throws MissingNetworkParameter |
||
172 | * @see NetworkInterface::getSignedMessageMagic |
||
173 | */ |
||
174 | public function getSignedMessageMagic(): string |
||
181 | |||
182 | 15 | /** |
|
183 | * @return string |
||
184 | * @throws MissingNetworkParameter |
||
185 | * @see NetworkInterface::getNetMagicBytes() |
||
186 | */ |
||
187 | public function getNetMagicBytes(): string |
||
194 | |||
195 | /** |
||
196 | * @return string |
||
197 | * @throws MissingBase58Prefix |
||
198 | */ |
||
199 | 47 | public function getPrivByte(): string |
|
203 | |||
204 | /** |
||
205 | * @return string |
||
206 | * @throws MissingBase58Prefix |
||
207 | * @see NetworkInterface::getAddressByte() |
||
208 | */ |
||
209 | 54 | public function getAddressByte(): string |
|
213 | /** |
||
214 | * @return int |
||
215 | * @throws MissingBase58Prefix |
||
216 | * @see NetworkInterface::getAddressPrefixLength() |
||
217 | */ |
||
218 | public function getAddressPrefixLength(): int |
||
222 | |||
223 | /** |
||
224 | * @return string |
||
225 | * @throws MissingBase58Prefix |
||
226 | * @see NetworkInterface::getP2shByte() |
||
227 | */ |
||
228 | public function getP2shByte(): string |
||
232 | |||
233 | /** |
||
234 | * @return int |
||
235 | * @throws MissingBase58Prefix |
||
236 | * @see NetworkInterface::getP2shPrefixLength() |
||
237 | */ |
||
238 | public function getP2shPrefixLength(): int |
||
242 | |||
243 | /** |
||
244 | * @return string |
||
245 | * @throws MissingBip32Prefix |
||
246 | * @see NetworkInterface::getHDPubByte() |
||
247 | */ |
||
248 | public function getHDPubByte(): string |
||
252 | |||
253 | /** |
||
254 | * @return string |
||
255 | * @throws MissingBip32Prefix |
||
256 | * @see NetworkInterface::getHDPrivByte() |
||
257 | */ |
||
258 | public function getHDPrivByte(): string |
||
262 | |||
263 | /** |
||
264 | * @return string |
||
265 | * @throws MissingBech32Prefix |
||
266 | * @see NetworkInterface::getSegwitBech32Prefix() |
||
267 | */ |
||
268 | public function getSegwitBech32Prefix(): string |
||
272 | } |
||
273 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.