coinex-api 0.0.89__py3-none-any.whl → 0.0.110__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of coinex-api might be problematic. Click here for more details.

Files changed (197) hide show
  1. coinex/ccxt/__init__.py +1 -1
  2. coinex/ccxt/async_support/__init__.py +1 -1
  3. coinex/ccxt/async_support/base/exchange.py +139 -10
  4. coinex/ccxt/async_support/base/throttler.py +1 -1
  5. coinex/ccxt/async_support/base/ws/cache.py +1 -0
  6. coinex/ccxt/async_support/base/ws/client.py +26 -4
  7. coinex/ccxt/async_support/coinex.py +2 -2
  8. coinex/ccxt/base/exchange.py +587 -91
  9. coinex/ccxt/base/types.py +11 -2
  10. coinex/ccxt/coinex.py +2 -2
  11. coinex/ccxt/pro/__init__.py +1 -1
  12. coinex/ccxt/pro/coinex.py +10 -7
  13. coinex/ccxt/static_dependencies/bip/__init__.py +6 -0
  14. coinex/ccxt/static_dependencies/bip/addr/P2PKH_addr.py +205 -0
  15. coinex/ccxt/static_dependencies/bip/addr/__init__.py +5 -0
  16. coinex/ccxt/static_dependencies/bip/addr/addr_dec_utils.py +125 -0
  17. coinex/ccxt/static_dependencies/bip/addr/addr_key_validator.py +162 -0
  18. coinex/ccxt/static_dependencies/bip/addr/iaddr_decoder.py +48 -0
  19. coinex/ccxt/static_dependencies/bip/addr/iaddr_encoder.py +50 -0
  20. coinex/ccxt/static_dependencies/bip/base58/__init__.py +3 -0
  21. coinex/ccxt/static_dependencies/bip/base58/base58.py +207 -0
  22. coinex/ccxt/static_dependencies/bip/base58/base58_ex.py +25 -0
  23. coinex/ccxt/static_dependencies/bip/base58/base58_xmr.py +155 -0
  24. coinex/ccxt/static_dependencies/bip/bech32/__init__.py +4 -0
  25. coinex/ccxt/static_dependencies/bip/bech32/bch_bech32.py +220 -0
  26. coinex/ccxt/static_dependencies/bip/bech32/bech32.py +235 -0
  27. coinex/ccxt/static_dependencies/bip/bech32/bech32_base.py +246 -0
  28. coinex/ccxt/static_dependencies/bip/bech32/bech32_ex.py +25 -0
  29. coinex/ccxt/static_dependencies/bip/bech32/segwit_bech32.py +173 -0
  30. coinex/ccxt/static_dependencies/bip/bip32/__init__.py +14 -0
  31. coinex/ccxt/static_dependencies/bip/bip32/base/__init__.py +3 -0
  32. coinex/ccxt/static_dependencies/bip/bip32/base/bip32_base.py +581 -0
  33. coinex/ccxt/static_dependencies/bip/bip32/base/ibip32_key_derivator.py +83 -0
  34. coinex/ccxt/static_dependencies/bip/bip32/base/ibip32_mst_key_generator.py +47 -0
  35. coinex/ccxt/static_dependencies/bip/bip32/bip32_const.py +35 -0
  36. coinex/ccxt/static_dependencies/bip/bip32/bip32_ex.py +29 -0
  37. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_data.py +500 -0
  38. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_net_ver.py +83 -0
  39. coinex/ccxt/static_dependencies/bip/bip32/bip32_key_ser.py +294 -0
  40. coinex/ccxt/static_dependencies/bip/bip32/bip32_keys.py +457 -0
  41. coinex/ccxt/static_dependencies/bip/bip32/bip32_path.py +247 -0
  42. coinex/ccxt/static_dependencies/bip/bip32/bip32_utils.py +72 -0
  43. coinex/ccxt/static_dependencies/bip/bip32/kholaw/__init__.py +4 -0
  44. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519.py +82 -0
  45. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py +118 -0
  46. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py +204 -0
  47. coinex/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py +119 -0
  48. coinex/ccxt/static_dependencies/bip/bip32/slip10/__init__.py +1 -0
  49. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_key_derivator.py +200 -0
  50. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_mst_key_generator.py +168 -0
  51. coinex/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_secp256k1.py +82 -0
  52. coinex/ccxt/static_dependencies/bip/bip44/__init__.py +1 -0
  53. coinex/ccxt/static_dependencies/bip/bip44/bip44.py +265 -0
  54. coinex/ccxt/static_dependencies/bip/bip44_base/__init__.py +3 -0
  55. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_base.py +624 -0
  56. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_base_ex.py +25 -0
  57. coinex/ccxt/static_dependencies/bip/bip44_base/bip44_keys.py +225 -0
  58. coinex/ccxt/static_dependencies/bip/coin_conf/__init__.py +2 -0
  59. coinex/ccxt/static_dependencies/bip/coin_conf/coin_conf.py +68 -0
  60. coinex/ccxt/static_dependencies/bip/coin_conf/coins_conf.py +890 -0
  61. coinex/ccxt/static_dependencies/bip/conf/__init__.py +0 -0
  62. coinex/ccxt/static_dependencies/bip/conf/bip44/__init__.py +3 -0
  63. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_coins.py +126 -0
  64. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_conf.py +1360 -0
  65. coinex/ccxt/static_dependencies/bip/conf/bip44/bip44_conf_getter.py +153 -0
  66. coinex/ccxt/static_dependencies/bip/conf/bip49/__init__.py +3 -0
  67. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_coins.py +53 -0
  68. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_conf.py +366 -0
  69. coinex/ccxt/static_dependencies/bip/conf/bip49/bip49_conf_getter.py +80 -0
  70. coinex/ccxt/static_dependencies/bip/conf/bip84/__init__.py +3 -0
  71. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_coins.py +39 -0
  72. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_conf.py +113 -0
  73. coinex/ccxt/static_dependencies/bip/conf/bip84/bip84_conf_getter.py +66 -0
  74. coinex/ccxt/static_dependencies/bip/conf/bip86/__init__.py +3 -0
  75. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_coins.py +37 -0
  76. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_conf.py +83 -0
  77. coinex/ccxt/static_dependencies/bip/conf/bip86/bip86_conf_getter.py +64 -0
  78. coinex/ccxt/static_dependencies/bip/conf/common/__init__.py +8 -0
  79. coinex/ccxt/static_dependencies/bip/conf/common/atom_addr.py +104 -0
  80. coinex/ccxt/static_dependencies/bip/conf/common/bip_bitcoin_cash_conf.py +106 -0
  81. coinex/ccxt/static_dependencies/bip/conf/common/bip_coin_conf.py +217 -0
  82. coinex/ccxt/static_dependencies/bip/conf/common/bip_coins.py +28 -0
  83. coinex/ccxt/static_dependencies/bip/conf/common/bip_conf_const.py +30 -0
  84. coinex/ccxt/static_dependencies/bip/conf/common/bip_litecoin_conf.py +121 -0
  85. coinex/ccxt/static_dependencies/bip/ecc/__init__.py +42 -0
  86. coinex/ccxt/static_dependencies/bip/ecc/common/__init__.py +0 -0
  87. coinex/ccxt/static_dependencies/bip/ecc/common/dummy_point.py +219 -0
  88. coinex/ccxt/static_dependencies/bip/ecc/common/ikeys.py +263 -0
  89. coinex/ccxt/static_dependencies/bip/ecc/common/ipoint.py +190 -0
  90. coinex/ccxt/static_dependencies/bip/ecc/conf.py +28 -0
  91. coinex/ccxt/static_dependencies/bip/ecc/curve/__init__.py +0 -0
  92. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve.py +121 -0
  93. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_getter.py +74 -0
  94. coinex/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_types.py +37 -0
  95. coinex/ccxt/static_dependencies/bip/ecc/ecdsa/__init__.py +0 -0
  96. coinex/ccxt/static_dependencies/bip/ecc/ecdsa/ecdsa_keys.py +36 -0
  97. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/__init__.py +0 -0
  98. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1.py +36 -0
  99. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_const.py +59 -0
  100. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_keys_ecdsa.py +248 -0
  101. coinex/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_point_ecdsa.py +234 -0
  102. coinex/ccxt/static_dependencies/bip/slip/__init__.py +0 -0
  103. coinex/ccxt/static_dependencies/bip/slip/slip173/__init__.py +1 -0
  104. coinex/ccxt/static_dependencies/bip/slip/slip173/slip173.py +60 -0
  105. coinex/ccxt/static_dependencies/bip/slip/slip32/__init__.py +4 -0
  106. coinex/ccxt/static_dependencies/bip/slip/slip32/slip32.py +322 -0
  107. coinex/ccxt/static_dependencies/bip/slip/slip32/slip32_key_net_ver.py +62 -0
  108. coinex/ccxt/static_dependencies/bip/slip/slip44/__init__.py +1 -0
  109. coinex/ccxt/static_dependencies/bip/slip/slip44/slip44.py +81 -0
  110. coinex/ccxt/static_dependencies/bip/utils/__init__.py +0 -0
  111. coinex/ccxt/static_dependencies/bip/utils/conf/__init__.py +1 -0
  112. coinex/ccxt/static_dependencies/bip/utils/conf/coin_names.py +59 -0
  113. coinex/ccxt/static_dependencies/bip/utils/crypto/__init__.py +10 -0
  114. coinex/ccxt/static_dependencies/bip/utils/crypto/aes_ecb.py +152 -0
  115. coinex/ccxt/static_dependencies/bip/utils/crypto/blake2.py +191 -0
  116. coinex/ccxt/static_dependencies/bip/utils/crypto/chacha20_poly1305.py +101 -0
  117. coinex/ccxt/static_dependencies/bip/utils/crypto/hash160.py +57 -0
  118. coinex/ccxt/static_dependencies/bip/utils/crypto/hmac.py +118 -0
  119. coinex/ccxt/static_dependencies/bip/utils/crypto/pbkdf2.py +66 -0
  120. coinex/ccxt/static_dependencies/bip/utils/crypto/ripemd.py +58 -0
  121. coinex/ccxt/static_dependencies/bip/utils/crypto/scrypt.py +66 -0
  122. coinex/ccxt/static_dependencies/bip/utils/crypto/sha2.py +182 -0
  123. coinex/ccxt/static_dependencies/bip/utils/crypto/sha3.py +99 -0
  124. coinex/ccxt/static_dependencies/bip/utils/misc/__init__.py +7 -0
  125. coinex/ccxt/static_dependencies/bip/utils/misc/algo.py +108 -0
  126. coinex/ccxt/static_dependencies/bip/utils/misc/base32.py +151 -0
  127. coinex/ccxt/static_dependencies/bip/utils/misc/bit.py +115 -0
  128. coinex/ccxt/static_dependencies/bip/utils/misc/bytes.py +200 -0
  129. coinex/ccxt/static_dependencies/bip/utils/misc/data_bytes.py +181 -0
  130. coinex/ccxt/static_dependencies/bip/utils/misc/integer.py +97 -0
  131. coinex/ccxt/static_dependencies/bip/utils/misc/string.py +54 -0
  132. coinex/ccxt/static_dependencies/bip/utils/typing/__init__.py +1 -0
  133. coinex/ccxt/static_dependencies/bip/utils/typing/literal.py +27 -0
  134. coinex/ccxt/static_dependencies/bip/wif/__init__.py +1 -0
  135. coinex/ccxt/static_dependencies/bip/wif/wif.py +144 -0
  136. coinex/ccxt/static_dependencies/dydx_v4_client/amino/amino_pb2.py +31 -0
  137. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/base/v1beta1/coin_pb2.py +47 -0
  138. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/keys_pb2.py +33 -0
  139. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/v1beta1/multisig_pb2.py +33 -0
  140. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/secp256k1/keys_pb2.py +34 -0
  141. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/msg/v1/msg_pb2.py +27 -0
  142. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/signing/v1beta1/signing_pb2.py +38 -0
  143. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/v1beta1/tx_pb2.py +75 -0
  144. coinex/ccxt/static_dependencies/dydx_v4_client/cosmos_proto/cosmos_pb2.py +36 -0
  145. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/accountplus_pb2.py +31 -0
  146. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/genesis_pb2.py +40 -0
  147. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/models_pb2.py +26 -0
  148. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/params_pb2.py +29 -0
  149. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/query_pb2.py +57 -0
  150. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/tx_pb2.py +51 -0
  151. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/block_rate_limit_config_pb2.py +37 -0
  152. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/clob_pair_pb2.py +41 -0
  153. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/equity_tier_limit_config_pb2.py +35 -0
  154. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/finalize_block_pb2.py +27 -0
  155. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_config_pb2.py +39 -0
  156. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_pb2.py +38 -0
  157. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/matches_pb2.py +55 -0
  158. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/mev_pb2.py +49 -0
  159. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/operation_pb2.py +32 -0
  160. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_pb2.py +86 -0
  161. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_removals_pb2.py +32 -0
  162. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/process_proposer_matches_events_pb2.py +42 -0
  163. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/query_pb2.py +124 -0
  164. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/streaming_pb2.py +29 -0
  165. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/tx_pb2.py +117 -0
  166. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/genesis_pb2.py +26 -0
  167. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/query_pb2.py +26 -0
  168. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/transfer_pb2.py +61 -0
  169. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/tx_pb2.py +37 -0
  170. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/asset_position_pb2.py +29 -0
  171. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/genesis_pb2.py +30 -0
  172. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/perpetual_position_pb2.py +33 -0
  173. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/query_pb2.py +63 -0
  174. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/streaming_pb2.py +31 -0
  175. coinex/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/subaccount_pb2.py +33 -0
  176. coinex/ccxt/static_dependencies/dydx_v4_client/gogoproto/gogo_pb2.py +102 -0
  177. coinex/ccxt/static_dependencies/dydx_v4_client/registry.py +38 -0
  178. coinex/ccxt/static_dependencies/ecdsa/ellipticcurve.py +842 -0
  179. coinex/ccxt/static_dependencies/ecdsa/keys.py +15 -4
  180. coinex/ccxt/static_dependencies/mnemonic/__init__.py +4 -0
  181. coinex/ccxt/static_dependencies/mnemonic/mnemonic.py +282 -0
  182. coinex/ccxt/static_dependencies/mnemonic/py.typed +1 -0
  183. coinex/ccxt/static_dependencies/mnemonic/wordlist/chinese_simplified.txt +2048 -0
  184. coinex/ccxt/static_dependencies/mnemonic/wordlist/chinese_traditional.txt +2048 -0
  185. coinex/ccxt/static_dependencies/mnemonic/wordlist/czech.txt +2048 -0
  186. coinex/ccxt/static_dependencies/mnemonic/wordlist/english.txt +2048 -0
  187. coinex/ccxt/static_dependencies/mnemonic/wordlist/french.txt +2048 -0
  188. coinex/ccxt/static_dependencies/mnemonic/wordlist/italian.txt +2048 -0
  189. coinex/ccxt/static_dependencies/mnemonic/wordlist/japanese.txt +2048 -0
  190. coinex/ccxt/static_dependencies/mnemonic/wordlist/korean.txt +2048 -0
  191. coinex/ccxt/static_dependencies/mnemonic/wordlist/portuguese.txt +2048 -0
  192. coinex/ccxt/static_dependencies/mnemonic/wordlist/russian.txt +2048 -0
  193. coinex/ccxt/static_dependencies/mnemonic/wordlist/spanish.txt +2048 -0
  194. coinex/ccxt/static_dependencies/mnemonic/wordlist/turkish.txt +2048 -0
  195. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/METADATA +3 -3
  196. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/RECORD +197 -17
  197. {coinex_api-0.0.89.dist-info → coinex_api-0.0.110.dist-info}/WHEEL +1 -1
@@ -0,0 +1,217 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with helper class for generic BIP coins configuration handling."""
22
+
23
+ # Imports
24
+ from typing import Any, Dict, Optional, Tuple, Type
25
+
26
+ from ...addr.iaddr_encoder import IAddrEncoder
27
+ from ...bip32 import Bip32Base, Bip32KeyNetVersions, Bip32PublicKey
28
+ from ...utils.conf import CoinNames as UtilsCoinNames
29
+
30
+
31
+ class BipCoinFctCallsConf:
32
+ """Bip coin function calls configuration class."""
33
+
34
+ m_fct_names: Tuple[str, ...]
35
+
36
+ def __init__(self,
37
+ *args: str) -> None:
38
+ """
39
+ Construct class.
40
+
41
+ Args:
42
+ args (str): Function names to be called
43
+ """
44
+ self.m_fct_names = args
45
+
46
+ def ResolveCalls(self,
47
+ pub_key: Bip32PublicKey) -> Any:
48
+ """
49
+ Resolve function calls and get the result.
50
+
51
+ Args:
52
+ pub_key (Bip32PublicKey object): Bip32PublicKey object
53
+
54
+ Returns:
55
+ Any: Result
56
+ """
57
+ res = pub_key
58
+ for fct_call in self.m_fct_names:
59
+ res = getattr(res, fct_call)()
60
+ return res
61
+
62
+
63
+ class BipCoinConf: # pylint: disable=too-many-instance-attributes
64
+ """Bip coin configuration class."""
65
+
66
+ m_coin_names: UtilsCoinNames
67
+ m_coin_idx: int
68
+ m_is_testnet: bool
69
+ m_def_path: str
70
+ m_key_net_ver: Bip32KeyNetVersions
71
+ m_wif_net_ver: Optional[bytes]
72
+ m_bip32_cls: Type[Bip32Base]
73
+ m_addr_params: Dict[str, Any]
74
+ # m_addr_cls: Type[IAddrEncoder]
75
+ m_any_addr_params_fct_call: bool
76
+
77
+ def __init__(self, # pylint: disable=too-many-arguments
78
+ coin_names: UtilsCoinNames,
79
+ coin_idx: int,
80
+ is_testnet: bool,
81
+ def_path: str,
82
+ key_net_ver: Bip32KeyNetVersions,
83
+ wif_net_ver: Optional[bytes],
84
+ bip32_cls: Type[Bip32Base],
85
+ # addr_cls: Type[IAddrEncoder],
86
+ addr_params: Dict[str, Any]) -> None:
87
+ """
88
+ Construct class.
89
+
90
+ Args:
91
+ coin_names (CoinNames object) : Coin names
92
+ coin_idx (int) : Coin index
93
+ is_testnet (bool) : Test net flag
94
+ def_path (str) : Default path
95
+ key_net_ver (Bip32KeyNetVersions object): Key net versions
96
+ wif_net_ver (bytes) : WIF net version, None if not supported
97
+ bip32_cls (Bip32Base class) : Bip32 class
98
+ addr_params (dict) : Address parameters
99
+ addr_cls (IAddrEncoder class) : Address class
100
+ """
101
+ self.m_coin_names = coin_names
102
+ self.m_coin_idx = coin_idx
103
+ self.m_is_testnet = is_testnet
104
+ self.m_def_path = def_path
105
+ self.m_key_net_ver = key_net_ver
106
+ self.m_wif_net_ver = wif_net_ver
107
+ self.m_bip32_cls = bip32_cls
108
+ self.m_addr_params = addr_params
109
+ self.m_any_addr_params_fct_call = any(
110
+ (isinstance(param_val, BipCoinFctCallsConf) for param_val in addr_params.values())
111
+ )
112
+ # self.m_addr_cls = addr_cls
113
+
114
+ def CoinNames(self) -> UtilsCoinNames:
115
+ """
116
+ Get coin names.
117
+
118
+ Returns:
119
+ CoinNames object: CoinNames object
120
+ """
121
+ return self.m_coin_names
122
+
123
+ def CoinIndex(self) -> int:
124
+ """
125
+ Get coin index.
126
+
127
+ Returns:
128
+ int: Coin index
129
+ """
130
+ return self.m_coin_idx
131
+
132
+ def IsTestNet(self) -> bool:
133
+ """
134
+ Get if test net.
135
+
136
+ Returns:
137
+ bool: True if test net, false otherwise
138
+ """
139
+ return self.m_is_testnet
140
+
141
+ def DefaultPath(self) -> str:
142
+ """
143
+ Get the default derivation path.
144
+
145
+ Returns:
146
+ str: Default derivation path
147
+ """
148
+ return self.m_def_path
149
+
150
+ def KeyNetVersions(self) -> Bip32KeyNetVersions:
151
+ """
152
+ Get key net versions.
153
+
154
+ Returns:
155
+ Bip32KeyNetVersions object: Bip32KeyNetVersions object
156
+ """
157
+ return self.m_key_net_ver
158
+
159
+ def WifNetVersion(self) -> Optional[bytes]:
160
+ """
161
+ Get WIF net version.
162
+
163
+ Returns:
164
+ bytes: WIF net version bytes
165
+ None: If WIF is not supported
166
+ """
167
+ return self.m_wif_net_ver
168
+
169
+ def Bip32Class(self) -> Type[Bip32Base]:
170
+ """
171
+ Get the Bip32 class.
172
+
173
+ Returns:
174
+ Bip32Base class: Bip32Base class
175
+ """
176
+ return self.m_bip32_cls
177
+
178
+ def AddrParams(self) -> Dict[str, Any]:
179
+ """
180
+ Get the address parameters.
181
+
182
+ Returns:
183
+ dict: Address parameters
184
+ """
185
+ return self.m_addr_params
186
+
187
+ def AddrParamsWithResolvedCalls(self,
188
+ pub_key: Bip32PublicKey) -> Dict[str, Any]:
189
+ """
190
+ Get the address parameters with resolved function calls.
191
+
192
+ Args:
193
+ pub_key (Bip32PublicKey object): Bip32PublicKey object
194
+
195
+ Returns:
196
+ dict: Address parameters
197
+ """
198
+ addr_params = self.AddrParams()
199
+
200
+ # Just use the internal object if nothing to be resolved to avoid creating a new one
201
+ if not self.m_any_addr_params_fct_call:
202
+ return addr_params
203
+
204
+ # Create a new dictionary with resolved function calls
205
+ return {
206
+ param_name: param_val.ResolveCalls(pub_key) if isinstance(param_val, BipCoinFctCallsConf) else param_val
207
+ for param_name, param_val in addr_params.items()
208
+ }
209
+
210
+ # def AddrClass(self) -> Type[IAddrEncoder]:
211
+ # """
212
+ # Get the address class.
213
+
214
+ # Returns:
215
+ # IAddrEncoder class: Address class
216
+ # """
217
+ # return self.m_addr_cls
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module for generic BIP coins enum."""
22
+
23
+ # Imports
24
+ from enum import Enum
25
+
26
+
27
+ class BipCoins(Enum):
28
+ """Base enum for bip coins."""
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module for generic BIP configuration constants."""
22
+
23
+ # Hardened default path (full)
24
+ DER_PATH_HARDENED_FULL: str = "0'/0'/0'"
25
+ # Hardened default path (mid)
26
+ DER_PATH_HARDENED_MID: str = "0'/0'"
27
+ # Hardened default path (short)
28
+ DER_PATH_HARDENED_SHORT: str = "0'"
29
+ # Non-hardened default path (full)
30
+ DER_PATH_NON_HARDENED_FULL: str = "0'/0/0"
@@ -0,0 +1,121 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with helper class for Litecoin configuration handling."""
22
+
23
+ # Imports
24
+ from typing import Any, Dict, Type
25
+
26
+ from bip_utils.addr import IAddrEncoder
27
+ from bip_utils.bip.bip32 import Bip32KeyNetVersions
28
+ from .bip_coin_conf import Bip32Base, BipCoinConf
29
+ from bip_utils.utils.conf import CoinNames
30
+
31
+
32
+ class BipLitecoinConf(BipCoinConf):
33
+ """
34
+ Litecoin configuration class.
35
+ It allows to return different addresses and key net versions depending on the configuration.
36
+ """
37
+
38
+ m_alt_key_net_ver: Bip32KeyNetVersions
39
+ m_use_alt_key_net_ver: bool
40
+ m_use_depr_addr: bool
41
+
42
+ def __init__(self, # pylint: disable=too-many-arguments
43
+ coin_names: CoinNames,
44
+ coin_idx: int,
45
+ is_testnet: bool,
46
+ def_path: str,
47
+ key_net_ver: Bip32KeyNetVersions,
48
+ alt_key_net_ver: Bip32KeyNetVersions,
49
+ wif_net_ver: bytes,
50
+ bip32_cls: Type[Bip32Base],
51
+ addr_cls: Type[IAddrEncoder],
52
+ addr_params: Dict[str, Any]) -> None:
53
+ """
54
+ Construct class.
55
+
56
+ Args:
57
+ coin_names (CoinNames object) : Coin names
58
+ coin_idx (int) : Coin index
59
+ is_testnet (bool) : Test net flag
60
+ def_path (str) : Default path
61
+ key_net_ver (Bip32KeyNetVersions object) : Key net versions
62
+ alt_key_net_ver (Bip32KeyNetVersions object): Key net versions (alternate)
63
+ wif_net_ver (bytes) : WIF net version
64
+ bip32_cls (Bip32Base class) : Bip32 class
65
+ addr_params (dict) : Address parameters
66
+ addr_cls (IAddrEncoder class) : Address class
67
+ """
68
+ super().__init__(coin_names=coin_names,
69
+ coin_idx=coin_idx,
70
+ is_testnet=is_testnet,
71
+ def_path=def_path,
72
+ key_net_ver=key_net_ver,
73
+ wif_net_ver=wif_net_ver,
74
+ bip32_cls=bip32_cls,
75
+ addr_cls=addr_cls,
76
+ addr_params=addr_params)
77
+
78
+ self.m_alt_key_net_ver = alt_key_net_ver
79
+ self.m_use_alt_key_net_ver = False
80
+ self.m_use_depr_addr = False
81
+
82
+ def UseAlternateKeyNetVersions(self,
83
+ value: bool) -> None:
84
+ """
85
+ Select if use the alternate key net version.
86
+
87
+ Args:
88
+ value (bool): True for using alternate key net version, false for using the standard one
89
+ """
90
+ self.m_use_alt_key_net_ver = value
91
+
92
+ def UseDeprecatedAddress(self,
93
+ value: bool) -> None:
94
+ """
95
+ Select if use the deprecated address.
96
+
97
+ Args:
98
+ value (bool): True for using deprecated address, false for using the standard one
99
+ """
100
+ self.m_use_depr_addr = value
101
+
102
+ def KeyNetVersions(self) -> Bip32KeyNetVersions:
103
+ """
104
+ Get key net versions. It overrides the method in BipCoinConf.
105
+ Litecoin overrides the method because it can have 2 different key net versions.
106
+
107
+ Returns:
108
+ Bip32KeyNetVersions object: Bip32KeyNetVersions object
109
+ """
110
+ return self.m_alt_key_net_ver if self.m_use_alt_key_net_ver else self.m_key_net_ver
111
+
112
+ def AddrParams(self) -> Dict[str, Any]:
113
+ """
114
+ Get the address parameters. It overrides the method in BipCoinConf.
115
+
116
+ Returns:
117
+ dict: Address parameters
118
+ """
119
+ return ({"net_ver": self.m_addr_params["depr_net_ver"]}
120
+ if self.m_use_depr_addr
121
+ else {"net_ver": self.m_addr_params["std_net_ver"]})
@@ -0,0 +1,42 @@
1
+ # Common
2
+ from .common.ikeys import IPrivateKey, IPublicKey
3
+ from .common.ipoint import IPoint
4
+
5
+ # Curve
6
+ from .curve.elliptic_curve import EllipticCurve
7
+ from .curve.elliptic_curve_getter import EllipticCurveGetter
8
+ from .curve.elliptic_curve_types import EllipticCurveTypes
9
+
10
+ # ed25519
11
+ # from .ed25519.ed25519 import Ed25519
12
+ # from .ed25519.ed25519_keys import Ed25519PrivateKey, Ed25519PublicKey
13
+ # from .ed25519.ed25519_point import Ed25519Point
14
+ # from .ed25519.ed25519_utils import Ed25519Utils
15
+
16
+ # ed25519-blake2b
17
+ # from .ed25519_blake2b.ed25519_blake2b import Ed25519Blake2b
18
+ # from .ed25519_blake2b.ed25519_blake2b_keys import Ed25519Blake2bPrivateKey, Ed25519Blake2bPublicKey
19
+ # from .ed25519_blake2b.ed25519_blake2b_point import Ed25519Blake2bPoint
20
+
21
+ # ed25519-kholaw
22
+ # from .ed25519_kholaw.ed25519_kholaw import Ed25519Kholaw
23
+ # from .ed25519_kholaw.ed25519_kholaw_keys import Ed25519KholawPrivateKey, Ed25519KholawPublicKey
24
+ # from .ed25519_kholaw.ed25519_kholaw_point import Ed25519KholawPoint
25
+
26
+ # ed25519-monero
27
+ # from .ed25519_monero.ed25519_monero import Ed25519Monero
28
+ # from .ed25519_monero.ed25519_monero_keys import Ed25519MoneroPrivateKey, Ed25519MoneroPublicKey
29
+ # from .ed25519_monero.ed25519_monero_point import Ed25519MoneroPoint
30
+
31
+ # nist256p1
32
+ # from .nist256p1.nist256p1 import Nist256p1
33
+ # from .nist256p1.nist256p1_keys import Nist256p1PrivateKey, Nist256p1PublicKey
34
+ # from .nist256p1.nist256p1_point import Nist256p1Point
35
+
36
+ # secp256k1
37
+ from .secp256k1.secp256k1 import Secp256k1, Secp256k1Point, Secp256k1PrivateKey, Secp256k1PublicKey
38
+
39
+ # sr25519
40
+ # from .sr25519.sr25519 import Sr25519
41
+ # from .sr25519.sr25519_keys import Sr25519PrivateKey, Sr25519PublicKey
42
+ # from .sr25519.sr25519_point import Sr25519Point
@@ -0,0 +1,219 @@
1
+ # Copyright (c) 2021 Emanuele Bellocchia
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ """Module with helper class for representing a dummy point."""
22
+
23
+ # Imports
24
+ from abc import ABC
25
+ from typing import Any
26
+
27
+ from bip_utils.ecc.common.ipoint import IPoint
28
+ from bip_utils.utils.misc import BytesUtils, DataBytes, IntegerUtils
29
+
30
+
31
+ class DummyPointConst:
32
+ """Class container for dummy point constants."""
33
+
34
+ # Point coordinate length in bytes
35
+ POINT_COORD_BYTE_LEN: int = 32
36
+
37
+
38
+ class DummyPoint(IPoint, ABC):
39
+ """Dummy point class."""
40
+
41
+ m_x: int
42
+ m_y: int
43
+
44
+ @classmethod
45
+ def FromBytes(cls,
46
+ point_bytes: bytes) -> IPoint:
47
+ """
48
+ Construct class from point bytes.
49
+
50
+ Args:
51
+ point_bytes (bytes): Point bytes
52
+
53
+ Returns:
54
+ IPoint: IPoint object
55
+ """
56
+ return cls(
57
+ (
58
+ BytesUtils.ToInteger(point_bytes[:DummyPointConst.POINT_COORD_BYTE_LEN]),
59
+ BytesUtils.ToInteger(point_bytes[DummyPointConst.POINT_COORD_BYTE_LEN:])
60
+ )
61
+ )
62
+
63
+ @classmethod
64
+ def FromCoordinates(cls,
65
+ x: int,
66
+ y: int) -> IPoint:
67
+ """
68
+ Construct class from point coordinates.
69
+
70
+ Args:
71
+ x (int): X coordinate of the point
72
+ y (int): Y coordinate of the point
73
+
74
+ Returns:
75
+ IPoint: IPoint object
76
+ """
77
+ return cls((x, y))
78
+
79
+ def __init__(self,
80
+ point_obj: Any) -> None:
81
+ """
82
+ Construct class from point object.
83
+
84
+ Args:
85
+ point_obj (class): Point object
86
+
87
+ Raises:
88
+ TypeError: If point object is not of the correct type
89
+ """
90
+ if (not isinstance(point_obj, tuple)
91
+ or len(point_obj) != 2
92
+ or not isinstance(point_obj[0], int)
93
+ or not isinstance(point_obj[1], int)):
94
+ raise TypeError("Invalid point object type")
95
+ self.m_x = point_obj[0]
96
+ self.m_y = point_obj[1]
97
+
98
+ @staticmethod
99
+ def CoordinateLength() -> int:
100
+ """
101
+ Get the coordinate length.
102
+
103
+ Returns:
104
+ int: Coordinate key length
105
+ """
106
+ return DummyPointConst.POINT_COORD_BYTE_LEN
107
+
108
+ def UnderlyingObject(self) -> Any:
109
+ """
110
+ Get the underlying object.
111
+
112
+ Returns:
113
+ Any: Underlying object
114
+ """
115
+ return None
116
+
117
+ def X(self) -> int:
118
+ """
119
+ Get point X coordinate.
120
+
121
+ Returns:
122
+ int: Point X coordinate
123
+ """
124
+ return self.m_x
125
+
126
+ def Y(self) -> int:
127
+ """
128
+ Get point Y coordinate.
129
+
130
+ Returns:
131
+ int: Point Y coordinate
132
+ """
133
+ return self.m_y
134
+
135
+ def Raw(self) -> DataBytes:
136
+ """
137
+ Return the point raw bytes.
138
+
139
+ Returns:
140
+ DataBytes object: DataBytes object
141
+ """
142
+ x_bytes = IntegerUtils.ToBytes(self.m_x, bytes_num=DummyPointConst.POINT_COORD_BYTE_LEN)
143
+ y_bytes = IntegerUtils.ToBytes(self.m_y, bytes_num=DummyPointConst.POINT_COORD_BYTE_LEN)
144
+
145
+ return DataBytes(x_bytes + y_bytes)
146
+
147
+ def RawEncoded(self) -> DataBytes:
148
+ """
149
+ Return the encoded point raw bytes.
150
+
151
+ Returns:
152
+ DataBytes object: DataBytes object
153
+ """
154
+ return self.Raw()
155
+
156
+ def RawDecoded(self) -> DataBytes:
157
+ """
158
+ Return the decoded point raw bytes.
159
+
160
+ Returns:
161
+ DataBytes object: DataBytes object
162
+ """
163
+ return self.Raw()
164
+
165
+ def __add__(self,
166
+ point: IPoint) -> IPoint:
167
+ """
168
+ Add point to another point.
169
+
170
+ Args:
171
+ point (IPoint object): IPoint object
172
+
173
+ Returns:
174
+ IPoint object: IPoint object
175
+ """
176
+ return self.__class__(
177
+ (self.m_x + point.X(), self.m_y + point.Y())
178
+ )
179
+
180
+ def __radd__(self,
181
+ point: IPoint) -> IPoint:
182
+ """
183
+ Add point to another point.
184
+
185
+ Args:
186
+ point (IPoint object): IPoint object
187
+
188
+ Returns:
189
+ IPoint object: IPoint object
190
+ """
191
+ return self.__add__(point)
192
+
193
+ def __mul__(self,
194
+ scalar: int) -> IPoint:
195
+ """
196
+ Multiply point by a scalar.
197
+
198
+ Args:
199
+ scalar (int): scalar
200
+
201
+ Returns:
202
+ IPoint object: IPoint object
203
+ """
204
+ return self.__class__(
205
+ (self.m_x * scalar, self.m_y * scalar)
206
+ )
207
+
208
+ def __rmul__(self,
209
+ scalar: int) -> IPoint:
210
+ """
211
+ Multiply point by a scalar.
212
+
213
+ Args:
214
+ scalar (int): scalar
215
+
216
+ Returns:
217
+ IPoint object: IPoint object
218
+ """
219
+ return self.__mul__(scalar)