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,39 @@
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 BIP84 coins enum."""
22
+
23
+ # Imports
24
+ from enum import auto, unique
25
+
26
+ from .bip_coins import BipCoins
27
+
28
+
29
+ @unique
30
+ class Bip84Coins(BipCoins):
31
+ """Enumerative for supported BIP84 coins."""
32
+
33
+ # Main nets
34
+ BITCOIN = auto()
35
+ LITECOIN = auto()
36
+ # Test nets
37
+ BITCOIN_REGTEST = auto()
38
+ BITCOIN_TESTNET = auto()
39
+ LITECOIN_TESTNET = auto()
@@ -0,0 +1,113 @@
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 BIP84 coins configuration."""
22
+
23
+ # Imports
24
+ from bip_utils.addr import P2WPKHAddrEncoder
25
+ from bip_utils.bip.bip32 import Bip32KeyNetVersions, Bip32Slip10Secp256k1
26
+ from import DER_PATH_NON_HARDENED_FULL, BipCoinConf
27
+ from bip_utils.coin_conf import CoinsConf
28
+ from bip_utils.slip.slip44 import Slip44
29
+
30
+
31
+ # Bitcoin key net version for main net (zpub / zprv)
32
+ _BIP84_BTC_KEY_NET_VER_MAIN: Bip32KeyNetVersions = Bip32KeyNetVersions(b"\x04\xb2\x47\x46",
33
+ b"\x04\xb2\x43\x0c")
34
+ # Bitcoin key test net version for test net (vpub / vprv)
35
+ _BIP84_BTC_KEY_NET_VER_TEST: Bip32KeyNetVersions = Bip32KeyNetVersions(b"\x04\x5f\x1c\xf6",
36
+ b"\x04\x5f\x18\xbc")
37
+
38
+
39
+ class Bip84Conf:
40
+ """Class container for BIP84 configuration."""
41
+
42
+ # Configuration for Bitcoin main net
43
+ BitcoinMainNet: BipCoinConf = BipCoinConf(
44
+ coin_names=CoinsConf.BitcoinMainNet.CoinNames(),
45
+ coin_idx=Slip44.BITCOIN,
46
+ is_testnet=False,
47
+ def_path=DER_PATH_NON_HARDENED_FULL,
48
+ key_net_ver=_BIP84_BTC_KEY_NET_VER_MAIN,
49
+ wif_net_ver=CoinsConf.BitcoinMainNet.ParamByKey("wif_net_ver"),
50
+ bip32_cls=Bip32Slip10Secp256k1,
51
+ addr_cls=P2WPKHAddrEncoder,
52
+ addr_params={
53
+ "hrp": CoinsConf.BitcoinMainNet.ParamByKey("p2wpkh_hrp"),
54
+ },
55
+ )
56
+ # Configuration for Bitcoin regtest
57
+ BitcoinRegTest: BipCoinConf = BipCoinConf(
58
+ coin_names=CoinsConf.BitcoinRegTest.CoinNames(),
59
+ coin_idx=Slip44.TESTNET,
60
+ is_testnet=True,
61
+ def_path=DER_PATH_NON_HARDENED_FULL,
62
+ key_net_ver=_BIP84_BTC_KEY_NET_VER_TEST,
63
+ wif_net_ver=CoinsConf.BitcoinRegTest.ParamByKey("wif_net_ver"),
64
+ bip32_cls=Bip32Slip10Secp256k1,
65
+ addr_cls=P2WPKHAddrEncoder,
66
+ addr_params={
67
+ "hrp": CoinsConf.BitcoinRegTest.ParamByKey("p2wpkh_hrp"),
68
+ },
69
+ )
70
+ # Configuration for Bitcoin test net
71
+ BitcoinTestNet: BipCoinConf = BipCoinConf(
72
+ coin_names=CoinsConf.BitcoinTestNet.CoinNames(),
73
+ coin_idx=Slip44.TESTNET,
74
+ is_testnet=True,
75
+ def_path=DER_PATH_NON_HARDENED_FULL,
76
+ key_net_ver=_BIP84_BTC_KEY_NET_VER_TEST,
77
+ wif_net_ver=CoinsConf.BitcoinTestNet.ParamByKey("wif_net_ver"),
78
+ bip32_cls=Bip32Slip10Secp256k1,
79
+ addr_cls=P2WPKHAddrEncoder,
80
+ addr_params={
81
+ "hrp": CoinsConf.BitcoinTestNet.ParamByKey("p2wpkh_hrp"),
82
+ },
83
+ )
84
+
85
+ # Configuration for Litecoin main net
86
+ LitecoinMainNet: BipCoinConf = BipCoinConf(
87
+ coin_names=CoinsConf.LitecoinMainNet.CoinNames(),
88
+ coin_idx=Slip44.LITECOIN,
89
+ is_testnet=False,
90
+ def_path=DER_PATH_NON_HARDENED_FULL,
91
+ key_net_ver=_BIP84_BTC_KEY_NET_VER_MAIN,
92
+ wif_net_ver=CoinsConf.LitecoinMainNet.ParamByKey("wif_net_ver"),
93
+ bip32_cls=Bip32Slip10Secp256k1,
94
+ addr_cls=P2WPKHAddrEncoder,
95
+ addr_params={
96
+ "hrp": CoinsConf.LitecoinMainNet.ParamByKey("p2wpkh_hrp"),
97
+ },
98
+ )
99
+ # Configuration for Litecoin test net
100
+ LitecoinTestNet: BipCoinConf = BipCoinConf(
101
+ coin_names=CoinsConf.LitecoinTestNet.CoinNames(),
102
+ coin_idx=Slip44.TESTNET,
103
+ is_testnet=True,
104
+ def_path=DER_PATH_NON_HARDENED_FULL,
105
+ key_net_ver=Bip32KeyNetVersions(b"\x04\x36\xf6\xe1",
106
+ b"\x04\x36\xef\x7d"), # ttub / ttpv
107
+ wif_net_ver=CoinsConf.LitecoinTestNet.ParamByKey("wif_net_ver"),
108
+ bip32_cls=Bip32Slip10Secp256k1,
109
+ addr_cls=P2WPKHAddrEncoder,
110
+ addr_params={
111
+ "hrp": CoinsConf.LitecoinTestNet.ParamByKey("p2wpkh_hrp"),
112
+ },
113
+ )
@@ -0,0 +1,66 @@
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 getting BIP84 coins configuration."""
22
+
23
+ # Imports
24
+ from typing import Dict
25
+
26
+ from bip_utils.bip.conf.bip84.bip84_coins import Bip84Coins
27
+ from bip_utils.bip.conf.bip84.bip84_conf import Bip84Conf
28
+ from import BipCoinConf, BipCoins
29
+
30
+
31
+ class Bip84ConfGetterConst:
32
+ """Class container for BIP84 configuration getter constants."""
33
+
34
+ # Map from Bip84Coins to configuration classes
35
+ COIN_TO_CONF: Dict[BipCoins, BipCoinConf] = {
36
+ Bip84Coins.BITCOIN: Bip84Conf.BitcoinMainNet,
37
+ Bip84Coins.BITCOIN_REGTEST: Bip84Conf.BitcoinRegTest,
38
+ Bip84Coins.BITCOIN_TESTNET: Bip84Conf.BitcoinTestNet,
39
+ Bip84Coins.LITECOIN: Bip84Conf.LitecoinMainNet,
40
+ Bip84Coins.LITECOIN_TESTNET: Bip84Conf.LitecoinTestNet,
41
+ }
42
+
43
+
44
+ class Bip84ConfGetter:
45
+ """
46
+ BIP84 configuration getter class.
47
+ It allows to get the BIP84 configuration of a specific coin.
48
+ """
49
+
50
+ @staticmethod
51
+ def GetConfig(coin_type: BipCoins) -> BipCoinConf:
52
+ """
53
+ Get coin configuration.
54
+
55
+ Args:
56
+ coin_type (BipCoins): Coin type
57
+
58
+ Returns:
59
+ BipCoinConf: Coin configuration
60
+
61
+ Raises:
62
+ TypeError: If coin type is not of a Bip84Coins enumerative
63
+ """
64
+ if not isinstance(coin_type, Bip84Coins):
65
+ raise TypeError("Coin type is not an enumerative of Bip84Coins")
66
+ return Bip84ConfGetterConst.COIN_TO_CONF[coin_type]
@@ -0,0 +1,3 @@
1
+ from bip_utils.bip.conf.bip86.bip86_coins import Bip86Coins
2
+ from bip_utils.bip.conf.bip86.bip86_conf import Bip86Conf
3
+ from bip_utils.bip.conf.bip86.bip86_conf_getter import Bip86ConfGetter
@@ -0,0 +1,37 @@
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 BIP86 coins enum."""
22
+
23
+ # Imports
24
+ from enum import auto, unique
25
+
26
+ from .bip_coins import BipCoins
27
+
28
+
29
+ @unique
30
+ class Bip86Coins(BipCoins):
31
+ """Enumerative for supported BIP86 coins."""
32
+
33
+ # Main nets
34
+ BITCOIN = auto()
35
+ # Test nets
36
+ BITCOIN_REGTEST = auto()
37
+ BITCOIN_TESTNET = auto()
@@ -0,0 +1,83 @@
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 BIP86 coins configuration."""
22
+
23
+ # Imports
24
+ from bip_utils.addr import P2TRAddrEncoder
25
+ from bip_utils.bip.bip32 import Bip32Const, Bip32KeyNetVersions, Bip32Slip10Secp256k1
26
+ from import DER_PATH_NON_HARDENED_FULL, BipCoinConf
27
+ from bip_utils.coin_conf import CoinsConf
28
+ from bip_utils.slip.slip44 import Slip44
29
+
30
+
31
+ # Bitcoin key net version for main net (same as BIP32)
32
+ _BIP86_BTC_KEY_NET_VER_MAIN: Bip32KeyNetVersions = Bip32Const.MAIN_NET_KEY_NET_VERSIONS
33
+ # Bitcoin key net version for test net (same as BIP32)
34
+ _BIP86_BTC_KEY_NET_VER_TEST: Bip32KeyNetVersions = Bip32Const.TEST_NET_KEY_NET_VERSIONS
35
+
36
+
37
+ class Bip86Conf:
38
+ """Class container for BIP86 configuration."""
39
+
40
+ # Configuration for Bitcoin main net
41
+ BitcoinMainNet: BipCoinConf = BipCoinConf(
42
+ coin_names=CoinsConf.BitcoinMainNet.CoinNames(),
43
+ coin_idx=Slip44.BITCOIN,
44
+ is_testnet=False,
45
+ def_path=DER_PATH_NON_HARDENED_FULL,
46
+ key_net_ver=_BIP86_BTC_KEY_NET_VER_MAIN,
47
+ wif_net_ver=CoinsConf.BitcoinMainNet.ParamByKey("wif_net_ver"),
48
+ bip32_cls=Bip32Slip10Secp256k1,
49
+ addr_cls=P2TRAddrEncoder,
50
+ addr_params={
51
+ "hrp": CoinsConf.BitcoinMainNet.ParamByKey("p2tr_hrp"),
52
+ },
53
+ )
54
+
55
+ # Configuration for Bitcoin regtest
56
+ BitcoinRegTest: BipCoinConf = BipCoinConf(
57
+ coin_names=CoinsConf.BitcoinRegTest.CoinNames(),
58
+ coin_idx=Slip44.TESTNET,
59
+ is_testnet=True,
60
+ def_path=DER_PATH_NON_HARDENED_FULL,
61
+ key_net_ver=_BIP86_BTC_KEY_NET_VER_TEST,
62
+ wif_net_ver=CoinsConf.BitcoinRegTest.ParamByKey("wif_net_ver"),
63
+ bip32_cls=Bip32Slip10Secp256k1,
64
+ addr_cls=P2TRAddrEncoder,
65
+ addr_params={
66
+ "hrp": CoinsConf.BitcoinRegTest.ParamByKey("p2tr_hrp"),
67
+ },
68
+ )
69
+
70
+ # Configuration for Bitcoin test net
71
+ BitcoinTestNet: BipCoinConf = BipCoinConf(
72
+ coin_names=CoinsConf.BitcoinTestNet.CoinNames(),
73
+ coin_idx=Slip44.TESTNET,
74
+ is_testnet=True,
75
+ def_path=DER_PATH_NON_HARDENED_FULL,
76
+ key_net_ver=_BIP86_BTC_KEY_NET_VER_TEST,
77
+ wif_net_ver=CoinsConf.BitcoinTestNet.ParamByKey("wif_net_ver"),
78
+ bip32_cls=Bip32Slip10Secp256k1,
79
+ addr_cls=P2TRAddrEncoder,
80
+ addr_params={
81
+ "hrp": CoinsConf.BitcoinTestNet.ParamByKey("p2tr_hrp"),
82
+ },
83
+ )
@@ -0,0 +1,64 @@
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 getting BIP86 coins configuration."""
22
+
23
+ # Imports
24
+ from typing import Dict
25
+
26
+ from bip_utils.bip.conf.bip86.bip86_coins import Bip86Coins
27
+ from bip_utils.bip.conf.bip86.bip86_conf import Bip86Conf
28
+ from import BipCoinConf, BipCoins
29
+
30
+
31
+ class Bip86ConfGetterConst:
32
+ """Class container for BIP86 configuration getter constants."""
33
+
34
+ # Map from Bip86Coins to configuration classes
35
+ COIN_TO_CONF: Dict[BipCoins, BipCoinConf] = {
36
+ Bip86Coins.BITCOIN: Bip86Conf.BitcoinMainNet,
37
+ Bip86Coins.BITCOIN_REGTEST: Bip86Conf.BitcoinRegTest,
38
+ Bip86Coins.BITCOIN_TESTNET: Bip86Conf.BitcoinTestNet,
39
+ }
40
+
41
+
42
+ class Bip86ConfGetter:
43
+ """
44
+ BIP86 configuration getter class.
45
+ It allows to get the BIP86 configuration of a specific coin.
46
+ """
47
+
48
+ @staticmethod
49
+ def GetConfig(coin_type: BipCoins) -> BipCoinConf:
50
+ """
51
+ Get coin configuration.
52
+
53
+ Args:
54
+ coin_type (BipCoins): Coin type
55
+
56
+ Returns:
57
+ BipCoinConf: Coin configuration
58
+
59
+ Raises:
60
+ TypeError: If coin type is not of a Bip86Coins enumerative
61
+ """
62
+ if not isinstance(coin_type, Bip86Coins):
63
+ raise TypeError("Coin type is not an enumerative of Bip86Coins")
64
+ return Bip86ConfGetterConst.COIN_TO_CONF[coin_type]
@@ -0,0 +1,8 @@
1
+ # from .bip_bitcoin_cash_conf import BipBitcoinCashConf
2
+ # from .bip_coin_conf import BipCoinConf, BipCoinFctCallsConf
3
+ from .bip_coin_conf import BipCoinConf
4
+ from .bip_coins import BipCoins
5
+ from .bip_conf_const import (
6
+ DER_PATH_HARDENED_FULL, DER_PATH_HARDENED_MID, DER_PATH_HARDENED_SHORT, DER_PATH_NON_HARDENED_FULL
7
+ )
8
+ # from .bip_litecoin_conf import BipLitecoinConf
@@ -0,0 +1,104 @@
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 Atom address encoding/decoding."""
22
+
23
+ # Imports
24
+ from typing import Any, Union
25
+
26
+ from bip_utils.addr.addr_dec_utils import AddrDecUtils
27
+ from bip_utils.addr.addr_key_validator import AddrKeyValidator
28
+ from bip_utils.addr.iaddr_decoder import IAddrDecoder
29
+ from bip_utils.addr.iaddr_encoder import IAddrEncoder
30
+ from bip_utils.bech32 import Bech32ChecksumError, Bech32Decoder, Bech32Encoder
31
+ from bip_utils.ecc import IPublicKey
32
+ from bip_utils.utils.crypto import Hash160
33
+
34
+
35
+ class AtomAddrDecoder(IAddrDecoder):
36
+ """
37
+ Atom address decoder class.
38
+ It allows the Atom address decoding.
39
+ """
40
+
41
+ @staticmethod
42
+ def DecodeAddr(addr: str,
43
+ **kwargs: Any) -> bytes:
44
+ """
45
+ Decode an Algorand address to bytes.
46
+
47
+ Args:
48
+ addr (str): Address string
49
+
50
+ Other Parameters:
51
+ hrp (str): Expected HRP
52
+
53
+ Returns:
54
+ bytes: Public key hash bytes
55
+
56
+ Raises:
57
+ ValueError: If the address encoding is not valid
58
+ """
59
+ hrp = kwargs["hrp"]
60
+
61
+ try:
62
+ addr_dec_bytes = Bech32Decoder.Decode(hrp, addr)
63
+ except Bech32ChecksumError as ex:
64
+ raise ValueError("Invalid bech32 checksum") from ex
65
+
66
+ AddrDecUtils.ValidateLength(addr_dec_bytes,
67
+ Hash160.DigestSize())
68
+ return addr_dec_bytes
69
+
70
+
71
+ class AtomAddrEncoder(IAddrEncoder):
72
+ """
73
+ Atom address encoder class.
74
+ It allows the Atom address encoding.
75
+ """
76
+
77
+ @staticmethod
78
+ def EncodeKey(pub_key: Union[bytes, IPublicKey],
79
+ **kwargs: Any) -> str:
80
+ """
81
+ Encode a public key to Atom address.
82
+
83
+ Args:
84
+ pub_key (bytes or IPublicKey): Public key bytes or object
85
+
86
+ Other Parameters:
87
+ hrp (str): HRP
88
+
89
+ Returns:
90
+ str: Address string
91
+
92
+ Raises:
93
+ ValueError: If the public key is not valid
94
+ TypeError: If the public key is not secp256k1
95
+ """
96
+ hrp = kwargs["hrp"]
97
+
98
+ pub_key_obj = AddrKeyValidator.ValidateAndGetSecp256k1Key(pub_key)
99
+ return Bech32Encoder.Encode(hrp,
100
+ Hash160.QuickDigest(pub_key_obj.RawCompressed().ToBytes()))
101
+
102
+
103
+ # Deprecated: only for compatibility, Encoder class shall be used instead
104
+ AtomAddr = AtomAddrEncoder
@@ -0,0 +1,106 @@
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 Bitcoin Cash configuration handling."""
22
+
23
+ # Imports
24
+ from typing import Any, Dict, Type
25
+
26
+ from ..addr import IAddrEncoder
27
+ from ..bip32 import Bip32KeyNetVersions
28
+ from .bip_coin_conf import Bip32Base, BipCoinConf
29
+ from ..utils.conf import CoinNames
30
+
31
+
32
+ class BipBitcoinCashConf(BipCoinConf):
33
+ """
34
+ Bitcoin Cash configuration class.
35
+ It allows to return different addresses depending on the configuration.
36
+ """
37
+
38
+ m_addr_cls_legacy: Type[IAddrEncoder]
39
+ m_use_legacy_addr: bool
40
+
41
+ def __init__(self, # pylint: disable=too-many-arguments
42
+ coin_names: CoinNames,
43
+ coin_idx: int,
44
+ is_testnet: bool,
45
+ def_path: str,
46
+ key_net_ver: Bip32KeyNetVersions,
47
+ wif_net_ver: bytes,
48
+ bip32_cls: Type[Bip32Base],
49
+ addr_cls: Type[IAddrEncoder],
50
+ addr_cls_legacy: Type[IAddrEncoder],
51
+ addr_params: Dict[str, Any]) -> None:
52
+ """
53
+ Construct class.
54
+
55
+ Args:
56
+ coin_names (CoinNames object) : Coin names
57
+ coin_idx (int) : Coin index
58
+ is_testnet (bool) : Test net flag
59
+ def_path (str) : Default path
60
+ key_net_ver (Bip32KeyNetVersions object): Key net versions
61
+ wif_net_ver (bytes) : WIF net version
62
+ bip32_cls (Bip32Base class) : Bip32 class
63
+ addr_params (dict) : Address parameters
64
+ addr_cls (IAddrEncoder class) : Address class
65
+ addr_cls_legacy (IAddrEncoder class) : Legacy ddress class
66
+ """
67
+ super().__init__(coin_names=coin_names,
68
+ coin_idx=coin_idx,
69
+ is_testnet=is_testnet,
70
+ def_path=def_path,
71
+ key_net_ver=key_net_ver,
72
+ wif_net_ver=wif_net_ver,
73
+ bip32_cls=bip32_cls,
74
+ addr_cls=addr_cls,
75
+ addr_params=addr_params)
76
+
77
+ self.m_addr_cls_legacy = addr_cls_legacy
78
+ self.m_use_legacy_addr = False
79
+
80
+ def UseLegacyAddress(self,
81
+ value: bool) -> None:
82
+ """
83
+ Select if use the legacy address.
84
+
85
+ Args:
86
+ value (bool): True for using legacy address, false for using the standard one
87
+ """
88
+ self.m_use_legacy_addr = value
89
+
90
+ def AddrClass(self) -> Type[IAddrEncoder]:
91
+ """
92
+ Get the address type. It overrides the method in BipCoinConf.
93
+
94
+ Returns:
95
+ IAddrEncoder class: Address class
96
+ """
97
+ return self.m_addr_cls_legacy if self.m_use_legacy_addr else self.m_addr_cls
98
+
99
+ def AddrParams(self) -> Dict[str, Any]:
100
+ """
101
+ Get the address parameters. It overrides the method in BipCoinConf.
102
+
103
+ Returns:
104
+ dict: Address parameters
105
+ """
106
+ return self.m_addr_params["legacy"] if self.m_use_legacy_addr else self.m_addr_params["std"]