| 1952 | |
| 1953 | @staticmethod |
| 1954 | def binary_to_base58(b): |
| 1955 | if Exchange.base58_encoder is None: |
| 1956 | Exchange.base58_decoder = {} |
| 1957 | Exchange.base58_encoder = {} |
| 1958 | for i, c in enumerate(Exchange.base58_alphabet): |
| 1959 | Exchange.base58_decoder[c] = i |
| 1960 | Exchange.base58_encoder[i] = c |
| 1961 | result = 0 |
| 1962 | # undo decimal_to_bytes |
| 1963 | for byte in b: |
| 1964 | result *= 0x100 |
| 1965 | result += byte |
| 1966 | string = [] |
| 1967 | while result > 0: |
| 1968 | result, next_character = divmod(result, 58) |
| 1969 | string.append(Exchange.base58_encoder[next_character]) |
| 1970 | string.reverse() |
| 1971 | return ''.join(string) |
| 1972 | |
| 1973 | def parse_number(self, value, default=None): |
| 1974 | if value is None: |