diff --git a/src/base58.php b/src/base58.php index 1f0ef53..948b6d5 100644 --- a/src/base58.php +++ b/src/base58.php @@ -41,12 +41,13 @@ class base58 * * Convert a hexadecimal string to a binary array * - * @param string $hex A hexadecimal string to convert to a binary array + * @param string $hex A hexadecimal string to convert to a binary array * * @return array * + * @throws Exception */ - private function hex_to_bin($hex) + private function hex_to_bin($hex): array { if (!is_string($hex)) { throw new Exception('base58->hex_to_bin(): Invalid input type (must be a string)'); @@ -320,7 +321,7 @@ private function decode_block($data, $buf, $index) if ($res_size < self::$full_block_size && bcpow(2, 8 * $res_size) <= 0) { throw new Exception('base58->decode_block(): Integer overflow (bcpow(2, 8 * $res_size) exceeds the maximum 64bit integer)'); } - + $tmp_buf = self::uint64_to_8_be($res_num, $res_size); for ($i = 0, $iMax = count($tmp_buf); $i < $iMax; $i++) { $buf[$i + $index] = $tmp_buf[$i]; diff --git a/src/wordsets/chinese_simplified.ws.php b/src/mnemonic/chinese_simplified.php similarity index 99% rename from src/wordsets/chinese_simplified.ws.php rename to src/mnemonic/chinese_simplified.php index bb0c943..209eff2 100644 --- a/src/wordsets/chinese_simplified.ws.php +++ b/src/mnemonic/chinese_simplified.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class chinese_simplified implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "简体中文 (中国)"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 1; // first letter of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "的", @@ -1662,4 +1664,4 @@ static public function words() : array { "貌", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/dutch.ws.php b/src/mnemonic/dutch.php similarity index 99% rename from src/wordsets/dutch.ws.php rename to src/mnemonic/dutch.php index 6005986..54500f7 100644 --- a/src/wordsets/dutch.ws.php +++ b/src/mnemonic/dutch.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class dutch implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "Nederlands"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "aalglad", @@ -1659,7 +1661,7 @@ static public function words() : array { "zwepen", "zwiep", "zwijmel", - "zworen" + "zworen" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/english.ws.php b/src/mnemonic/english.php similarity index 99% rename from src/wordsets/english.ws.php rename to src/mnemonic/english.php index 9f96360..fcc0f49 100644 --- a/src/wordsets/english.ws.php +++ b/src/mnemonic/english.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class english implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,11 +14,11 @@ static public function name() : string { return "English"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { - return "English"; + return "English"; } /* Returns integer indicating length of unique prefix, @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 3; // first 3 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "abbey", @@ -1662,4 +1664,4 @@ static public function words() : array { "zoom", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/english_old.ws.php b/src/mnemonic/english_old.php similarity index 99% rename from src/wordsets/english_old.ws.php rename to src/mnemonic/english_old.php index 419a067..ad0783c 100644 --- a/src/wordsets/english_old.ws.php +++ b/src/mnemonic/english_old.php @@ -7,6 +7,8 @@ */ +use MoneroIntegrations\MoneroPhp\wordset; + class english_old implements wordset { /* Returns name of wordset in the wordset's native language. @@ -17,7 +19,7 @@ static public function name() : string { return "EnglishOld"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -30,13 +32,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 0; // require entire word. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "like", @@ -1667,4 +1669,4 @@ static public function words() : array { "weary", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/esperanto.ws.php b/src/mnemonic/esperanto.php similarity index 99% rename from src/wordsets/esperanto.ws.php rename to src/mnemonic/esperanto.php index de33c2d..874bea0 100644 --- a/src/wordsets/esperanto.ws.php +++ b/src/mnemonic/esperanto.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class esperanto implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "Esperanto"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "abako", @@ -1659,7 +1661,7 @@ static public function words() : array { "zoologio", "zorgi", "zukino", - "zumilo", + "zumilo", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/french.ws.php b/src/mnemonic/french.php similarity index 99% rename from src/wordsets/french.ws.php rename to src/mnemonic/french.php index 658c40d..505260c 100644 --- a/src/wordsets/french.ws.php +++ b/src/mnemonic/french.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class french implements wordset { /* Returns name of wordset in the wordset's native language. @@ -9,10 +11,10 @@ class french implements wordset { * if the language supports it. */ static public function name() : string { - return "Français"; + return "Français"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "abandon", @@ -1662,4 +1664,4 @@ static public function words() : array { "zoom", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/german.ws.php b/src/mnemonic/german.php similarity index 99% rename from src/wordsets/german.ws.php rename to src/mnemonic/german.php index 9805987..96c711b 100644 --- a/src/wordsets/german.ws.php +++ b/src/mnemonic/german.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class german implements wordset { /* Returns name of wordset in the wordset's native language. @@ -9,10 +11,10 @@ class german implements wordset { * if the language supports it. */ static public function name() : string { - return "Deutsch"; + return "Deutsch"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -26,13 +28,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "Abakus", @@ -1660,7 +1662,7 @@ static public function words() : array { "Zugvogel", "Zündung", "Zweck", - "Zyklop" + "Zyklop" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/italian.ws.php b/src/mnemonic/italian.php similarity index 99% rename from src/wordsets/italian.ws.php rename to src/mnemonic/italian.php index f730449..1d70c14 100644 --- a/src/wordsets/italian.ws.php +++ b/src/mnemonic/italian.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class italian implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "Italiano"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "abbinare", @@ -1659,7 +1661,7 @@ static public function words() : array { "zoccolo", "zolfo", "zombie", - "zucchero" + "zucchero" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/japanese.ws.php b/src/mnemonic/japanese.php similarity index 99% rename from src/wordsets/japanese.ws.php rename to src/mnemonic/japanese.php index 6e63d70..0627d18 100644 --- a/src/wordsets/japanese.ws.php +++ b/src/mnemonic/japanese.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class japanese implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "日本語"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 3; // first 3 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "あいこくしん", @@ -1659,7 +1661,7 @@ static public function words() : array { "ひさしぶり", "ひさん", "びじゅつかん", - "ひしょ" + "ひしょ" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/lojban.ws.php b/src/mnemonic/lojban.php similarity index 99% rename from src/wordsets/lojban.ws.php rename to src/mnemonic/lojban.php index 2219125..c286e36 100644 --- a/src/wordsets/lojban.ws.php +++ b/src/mnemonic/lojban.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class lojban implements wordset { /* Returns name of wordset in the wordset's native language. @@ -9,14 +11,14 @@ class lojban implements wordset { * if the language supports it. */ static public function name() : string { - return "Lojban"; + return "Lojban"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { - return "Lojban"; + return "Lojban"; } /* Returns integer indicating length of unique prefix, @@ -25,13 +27,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "backi", @@ -1662,4 +1664,4 @@ static public function words() : array { "snaxa'a", ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/portuguese.ws.php b/src/mnemonic/portuguese.php similarity index 99% rename from src/wordsets/portuguese.ws.php rename to src/mnemonic/portuguese.php index cee713d..7ef3c96 100644 --- a/src/wordsets/portuguese.ws.php +++ b/src/mnemonic/portuguese.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class portuguese implements wordset { /* Returns name of wordset in the wordset's native language. @@ -12,7 +14,7 @@ static public function name() : string { return "Português"; } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -26,13 +28,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "abaular", @@ -1663,4 +1665,4 @@ static public function words() : array { "zumbi" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/russian.ws.php b/src/mnemonic/russian.php similarity index 99% rename from src/wordsets/russian.ws.php rename to src/mnemonic/russian.php index 5c6a02d..14b57d1 100644 --- a/src/wordsets/russian.ws.php +++ b/src/mnemonic/russian.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class russian implements wordset { /* Returns name of wordset in the wordset's native language. @@ -10,10 +12,10 @@ class russian implements wordset { */ static public function name() : string { return "русский язык"; - + } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -26,13 +28,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 3; // first 3 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "абажур", @@ -1660,7 +1662,7 @@ static public function words() : array { "ясный", "яхта", "ячейка", - "ящик" + "ящик" ]; } -} \ No newline at end of file +} diff --git a/src/wordsets/spanish.ws.php b/src/mnemonic/spanish.php similarity index 99% rename from src/wordsets/spanish.ws.php rename to src/mnemonic/spanish.php index f5854b1..8d42bac 100644 --- a/src/wordsets/spanish.ws.php +++ b/src/mnemonic/spanish.php @@ -2,6 +2,8 @@ namespace MoneroIntegrations\MoneroPhp\mnemonic; +use MoneroIntegrations\MoneroPhp\wordset; + class spanish implements wordset { /* Returns name of wordset in the wordset's native language. @@ -10,10 +12,10 @@ class spanish implements wordset { */ static public function name() : string { return "Español"; - + } - /* Returns name of wordset in english. + /* Returns name of wordset in english. * This is a human-readable string, and should be capitalized */ static public function english_name() : string { @@ -27,13 +29,13 @@ static public function english_name() : string { * * A value of 0 indicates that there is no unique prefix * and the entire word must be used instead. - */ + */ static public function prefix_length() : int { return 4; // first 4 letters of each word in wordset is unique. } - + /* Returns an array of all words in the wordset. - */ + */ static public function words() : array { return [ "ábaco", @@ -1661,7 +1663,7 @@ static public function words() : array { "riqueza", "risa", "ritmo", - "rito" + "rito" ]; } -} \ No newline at end of file +}