libnexapy-test 0.1.0__tar.gz → 0.2.0__tar.gz

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.
Files changed (153) hide show
  1. {libnexapy_test-0.1.0/libnexapy_test.egg-info → libnexapy_test-0.2.0}/PKG-INFO +1 -1
  2. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0/libnexapy_test.egg-info}/PKG-INFO +1 -1
  3. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/libnexapy_test.egg-info/SOURCES.txt +1 -51
  4. libnexapy_test-0.2.0/libnexapy_test.egg-info/top_level.txt +1 -0
  5. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/pyproject.toml +1 -1
  6. libnexapy_test-0.1.0/libnexapy_test.egg-info/top_level.txt +0 -1
  7. libnexapy_test-0.1.0/src/__init__.py +0 -0
  8. libnexapy_test-0.1.0/src/common/__init__.py +0 -2
  9. libnexapy_test-0.1.0/src/common/class_types.py +0 -60
  10. libnexapy_test-0.1.0/src/common/types.py +0 -351
  11. libnexapy_test-0.1.0/src/core/address/address.py +0 -380
  12. libnexapy_test-0.1.0/src/core/address/address_formatter.py +0 -293
  13. libnexapy_test-0.1.0/src/core/block/block.py +0 -158
  14. libnexapy_test-0.1.0/src/core/block/block_header.py +0 -257
  15. libnexapy_test-0.1.0/src/core/grouptoken.py +0 -363
  16. libnexapy_test-0.1.0/src/core/message.py +0 -131
  17. libnexapy_test-0.1.0/src/core/network/network.py +0 -118
  18. libnexapy_test-0.1.0/src/core/network/network_manager.py +0 -131
  19. libnexapy_test-0.1.0/src/core/script/opcode.py +0 -312
  20. libnexapy_test-0.1.0/src/core/script/script.py +0 -841
  21. libnexapy_test-0.1.0/src/core/script/script_factory.py +0 -385
  22. libnexapy_test-0.1.0/src/core/transaction/input/input.py +0 -134
  23. libnexapy_test-0.1.0/src/core/transaction/input/public_key_hash.py +0 -47
  24. libnexapy_test-0.1.0/src/core/transaction/input/public_key_template.py +0 -47
  25. libnexapy_test-0.1.0/src/core/transaction/input/script_template.py +0 -154
  26. libnexapy_test-0.1.0/src/core/transaction/output.py +0 -161
  27. libnexapy_test-0.1.0/src/core/transaction/sighash_type.py +0 -246
  28. libnexapy_test-0.1.0/src/core/transaction/transaction.py +0 -506
  29. libnexapy_test-0.1.0/src/core/transaction/tx_builder.py +0 -228
  30. libnexapy_test-0.1.0/src/core/transaction/tx_signature.py +0 -85
  31. libnexapy_test-0.1.0/src/core/transaction/tx_signer.py +0 -164
  32. libnexapy_test-0.1.0/src/core/transaction/unspent_output.py +0 -79
  33. libnexapy_test-0.1.0/src/crypto/__init__.py +0 -3
  34. libnexapy_test-0.1.0/src/crypto/curve_utils.py +0 -43
  35. libnexapy_test-0.1.0/src/crypto/digital_signature.py +0 -73
  36. libnexapy_test-0.1.0/src/crypto/ecc_fast.py +0 -175
  37. libnexapy_test-0.1.0/src/crypto/ecdsa.py +0 -310
  38. libnexapy_test-0.1.0/src/crypto/hash.py +0 -64
  39. libnexapy_test-0.1.0/src/crypto/ripemd160.py +0 -408
  40. libnexapy_test-0.1.0/src/crypto/schnorr.py +0 -509
  41. libnexapy_test-0.1.0/src/crypto/secp256k1.py +0 -223
  42. libnexapy_test-0.1.0/src/crypto/signature.py +0 -244
  43. libnexapy_test-0.1.0/src/encoding/base32.py +0 -51
  44. libnexapy_test-0.1.0/src/encoding/base58.py +0 -165
  45. libnexapy_test-0.1.0/src/encoding/base58_check.py +0 -92
  46. libnexapy_test-0.1.0/src/encoding/buffer_reader.py +0 -159
  47. libnexapy_test-0.1.0/src/encoding/buffer_writer.py +0 -138
  48. libnexapy_test-0.1.0/src/keys/hd_private_key.py +0 -473
  49. libnexapy_test-0.1.0/src/keys/hd_public_key.py +0 -417
  50. libnexapy_test-0.1.0/src/keys/hdkey_utils.py +0 -139
  51. libnexapy_test-0.1.0/src/keys/private_key.py +0 -340
  52. libnexapy_test-0.1.0/src/keys/public_key.py +0 -394
  53. libnexapy_test-0.1.0/src/utils/buffer_utils.py +0 -47
  54. libnexapy_test-0.1.0/src/utils/common_utils.py +0 -4
  55. libnexapy_test-0.1.0/src/utils/num_utils.py +0 -81
  56. libnexapy_test-0.1.0/src/utils/unit_utils.py +0 -78
  57. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/LICENCE +0 -0
  58. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/MANIFEST.in +0 -0
  59. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/README.md +0 -0
  60. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/libnexapy_test.egg-info/dependency_links.txt +0 -0
  61. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/libnexapy_test.egg-info/requires.txt +0 -0
  62. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/COPYING +0 -0
  63. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/Makefile.am +0 -0
  64. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/README.md +0 -0
  65. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/autogen.sh +0 -0
  66. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/build-aux/m4/ax_jni_include_dir.m4 +0 -0
  67. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 +0 -0
  68. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/build-aux/m4/bitcoin_secp.m4 +0 -0
  69. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/configure.ac +0 -0
  70. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/contrib/lax_der_parsing.c +0 -0
  71. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/contrib/lax_der_parsing.h +0 -0
  72. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/contrib/lax_der_privatekey_parsing.c +0 -0
  73. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/contrib/lax_der_privatekey_parsing.h +0 -0
  74. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1.h +0 -0
  75. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1_ecdh.h +0 -0
  76. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1_multiset.h +0 -0
  77. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1_preallocated.h +0 -0
  78. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1_recovery.h +0 -0
  79. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/include/secp256k1_schnorr.h +0 -0
  80. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/libsecp256k1.pc.in +0 -0
  81. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/asm/field_10x26_arm.s +0 -0
  82. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/basic-config.h +0 -0
  83. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench.h +0 -0
  84. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_ecdh.c +0 -0
  85. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_ecmult.c +0 -0
  86. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_internal.c +0 -0
  87. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_multiset.c +0 -0
  88. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_recover.c +0 -0
  89. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_sign.c +0 -0
  90. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/bench_verify.c +0 -0
  91. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecdsa.h +0 -0
  92. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecdsa_impl.h +0 -0
  93. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/eckey.h +0 -0
  94. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/eckey_impl.h +0 -0
  95. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult.h +0 -0
  96. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult_const.h +0 -0
  97. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult_const_impl.h +0 -0
  98. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult_gen.h +0 -0
  99. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult_gen_impl.h +0 -0
  100. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/ecmult_impl.h +0 -0
  101. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field.h +0 -0
  102. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_10x26.h +0 -0
  103. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_10x26_impl.h +0 -0
  104. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_5x52.h +0 -0
  105. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_5x52_asm_impl.h +0 -0
  106. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_5x52_impl.h +0 -0
  107. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_5x52_int128_impl.h +0 -0
  108. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/field_impl.h +0 -0
  109. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/gen_context.c +0 -0
  110. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/group.h +0 -0
  111. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/group_impl.h +0 -0
  112. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/hash.h +0 -0
  113. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/hash_impl.h +0 -0
  114. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c +0 -0
  115. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h +0 -0
  116. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/java/org_bitcoin_Secp256k1Context.c +0 -0
  117. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/java/org_bitcoin_Secp256k1Context.h +0 -0
  118. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/ecdh/Makefile.am.include +0 -0
  119. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/ecdh/main_impl.h +0 -0
  120. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/ecdh/tests_impl.h +0 -0
  121. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/multiset/Makefile.am.include +0 -0
  122. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/multiset/main_impl.h +0 -0
  123. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/multiset/tests_impl.h +0 -0
  124. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/recovery/Makefile.am.include +0 -0
  125. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/recovery/main_impl.h +0 -0
  126. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/recovery/tests_impl.h +0 -0
  127. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/schnorr/Makefile.am.include +0 -0
  128. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/schnorr/main_impl.h +0 -0
  129. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/schnorr/schnorr.h +0 -0
  130. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/schnorr/schnorr_impl.h +0 -0
  131. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/modules/schnorr/tests_impl.h +0 -0
  132. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/num.h +0 -0
  133. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/num_gmp.h +0 -0
  134. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/num_gmp_impl.h +0 -0
  135. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/num_impl.h +0 -0
  136. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar.h +0 -0
  137. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_4x64.h +0 -0
  138. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_4x64_impl.h +0 -0
  139. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_8x32.h +0 -0
  140. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_8x32_impl.h +0 -0
  141. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_impl.h +0 -0
  142. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_low.h +0 -0
  143. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scalar_low_impl.h +0 -0
  144. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scratch.h +0 -0
  145. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/scratch_impl.h +0 -0
  146. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/secp256k1.c +0 -0
  147. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/testrand.h +0 -0
  148. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/testrand_impl.h +0 -0
  149. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/tests.c +0 -0
  150. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/tests_exhaustive.c +0 -0
  151. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/secp256k1/src/util.h +0 -0
  152. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/setup.cfg +0 -0
  153. {libnexapy_test-0.1.0 → libnexapy_test-0.2.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libnexapy_test
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A pure and powerful Python Nexa SDK library (TEST).
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libnexapy_test
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A pure and powerful Python Nexa SDK library (TEST).
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.12
@@ -97,54 +97,4 @@ secp256k1/src/modules/schnorr/Makefile.am.include
97
97
  secp256k1/src/modules/schnorr/main_impl.h
98
98
  secp256k1/src/modules/schnorr/schnorr.h
99
99
  secp256k1/src/modules/schnorr/schnorr_impl.h
100
- secp256k1/src/modules/schnorr/tests_impl.h
101
- src/__init__.py
102
- src/common/__init__.py
103
- src/common/class_types.py
104
- src/common/types.py
105
- src/core/grouptoken.py
106
- src/core/message.py
107
- src/core/address/address.py
108
- src/core/address/address_formatter.py
109
- src/core/block/block.py
110
- src/core/block/block_header.py
111
- src/core/network/network.py
112
- src/core/network/network_manager.py
113
- src/core/script/opcode.py
114
- src/core/script/script.py
115
- src/core/script/script_factory.py
116
- src/core/transaction/output.py
117
- src/core/transaction/sighash_type.py
118
- src/core/transaction/transaction.py
119
- src/core/transaction/tx_builder.py
120
- src/core/transaction/tx_signature.py
121
- src/core/transaction/tx_signer.py
122
- src/core/transaction/unspent_output.py
123
- src/core/transaction/input/input.py
124
- src/core/transaction/input/public_key_hash.py
125
- src/core/transaction/input/public_key_template.py
126
- src/core/transaction/input/script_template.py
127
- src/crypto/__init__.py
128
- src/crypto/curve_utils.py
129
- src/crypto/digital_signature.py
130
- src/crypto/ecc_fast.py
131
- src/crypto/ecdsa.py
132
- src/crypto/hash.py
133
- src/crypto/ripemd160.py
134
- src/crypto/schnorr.py
135
- src/crypto/secp256k1.py
136
- src/crypto/signature.py
137
- src/encoding/base32.py
138
- src/encoding/base58.py
139
- src/encoding/base58_check.py
140
- src/encoding/buffer_reader.py
141
- src/encoding/buffer_writer.py
142
- src/keys/hd_private_key.py
143
- src/keys/hd_public_key.py
144
- src/keys/hdkey_utils.py
145
- src/keys/private_key.py
146
- src/keys/public_key.py
147
- src/utils/buffer_utils.py
148
- src/utils/common_utils.py
149
- src/utils/num_utils.py
150
- src/utils/unit_utils.py
100
+ secp256k1/src/modules/schnorr/tests_impl.h
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "libnexapy_test"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "A pure and powerful Python Nexa SDK library (TEST)."
9
9
  readme = "README.md"
10
10
  license = "MIT"
File without changes
@@ -1,2 +0,0 @@
1
- from types import *
2
- from .class_types import FrozenClass, TypedClass
@@ -1,60 +0,0 @@
1
- from collections import defaultdict
2
- from types import UnionType
3
- from typing import get_type_hints, get_args
4
-
5
-
6
- # readonly class. attributes can not be added, deleted, or updated.
7
- class FrozenClass:
8
- def __init__(self):
9
- self._is_frozen = False
10
-
11
- def __setattr__(self, key, value):
12
- if key != "_is_frozen":
13
- if self.__dict__["_is_frozen"]:
14
- raise TypeError(f"{key} can not be updated. {self} is a frozen class.")
15
- object.__setattr__(self, key, value)
16
-
17
- def __delattr__(self, key):
18
- if self._is_frozen:
19
- raise TypeError(f"{key} can not be deleted. {self} is a frozen class.")
20
- object.__delattr__(self, key)
21
-
22
- def _freeze_attributes(self):
23
- self._is_frozen = True
24
-
25
-
26
- # A typed class can not add more attributes, delete existing ones, or assign values that are not the same type
27
- # as the existing value
28
- class TypedClass:
29
- def __init__(self):
30
- self._acceptable_types = defaultdict(lambda: set([type(None)]))
31
- self._enforced_types = False
32
- self._added_annotations = False
33
-
34
- def __setattr__(self, key, value):
35
- if "_acceptable_types" in self.__dict__ and "_enforced_types" in self.__dict__:
36
- if "_added_annotations" in self.__dict__ and self._added_annotations == False:
37
- hints = get_type_hints(type(self))
38
- if hints != {}:
39
- for k, v in hints.items():
40
- if isinstance(v, UnionType):
41
- self._acceptable_types[k].update(get_args(v))
42
- else:
43
- self._acceptable_types[k].add(v)
44
- object.__setattr__(self, "_added_annotations", True)
45
- if self.__dict__["_enforced_types"]:
46
- if self._enforced_types and type(value) not in self._acceptable_types[key]:
47
- raise TypeError(
48
- f"{self} is a typed class. {key} with acceptable types {self._acceptable_types[key]} can not updated with {value} of type {type(value)}"
49
- )
50
- else:
51
- self._acceptable_types[key].add(type(value))
52
- object.__setattr__(self, key, value)
53
-
54
- def __delattr__(self, key):
55
- if self._enforced_types:
56
- raise TypeError(f"{key} can not be deleted. {self} is a typed class.")
57
- object.__delattr__(self, key)
58
-
59
- def _enforce_attribute_types(self):
60
- self._enforced_types = True
@@ -1,351 +0,0 @@
1
- from enum import Enum, IntEnum, unique
2
- from typing import TypeVar
3
-
4
- from .class_types import TypedClass
5
- from src.core.network.network import Network
6
-
7
- COIN = 100
8
- MAX_MONEY = 21000000000000 * COIN
9
-
10
- """
11
- Any type that can be used where a big number is needed.
12
- """
13
- BigNumberish = TypeVar("BigNumberish", str, int)
14
-
15
- """
16
- Any type that can be used where a network is needed.
17
- """
18
- Networkish = TypeVar("Networkish", str, Network)
19
-
20
-
21
- @unique
22
- class EndianType(Enum):
23
- LITTLE = "little"
24
- BIG = "big"
25
-
26
-
27
- @unique
28
- class InputType(IntEnum):
29
- UTXO = 0
30
- READ_ONLY = 1
31
-
32
-
33
- @unique
34
- class OutputType(IntEnum):
35
- SATOSCRIPT = 0
36
- TEMPLATE = (1,)
37
- INFER = 0x8000 # Not a real type: implies the type should be infered from the script at construction time
38
-
39
-
40
- class InputSighashType(IntEnum):
41
- ALL = 0
42
- FIRSTN = 1
43
- THISIN = 2
44
- LAST_VALID = THISIN # end indicator
45
-
46
-
47
- class OutputSighashType(IntEnum):
48
- ALL = 0
49
- FIRSTN = 1
50
- TWO = 2
51
- LAST_VALID = TWO # end indicator
52
-
53
-
54
- # TODO - Doing abstract bases or interfaces was a mistake and all they did was cause a lot of problems.
55
- # remove them all at some point. Just use the classes instead and for serialisation use dicts where
56
- # bytes and bytearrays are stored as hex values
57
-
58
-
59
- class BufferParams(TypedClass):
60
- def __init__(self):
61
- super().__init__()
62
- self.buf = bytearray() # bytes
63
- self.pos = int() # int
64
- self._enforce_attribute_types() # no new attributes after this point.
65
-
66
-
67
- class BufferWriterOptions(TypedClass):
68
- def __init__(self):
69
- super().__init__()
70
- self.bufs: list[bytearray] = []
71
- self._enforce_attribute_types()
72
-
73
-
74
- class GroupIdData(TypedClass):
75
- def __init__(self):
76
- super().__init__()
77
- self.hash_buffer = bytearray()
78
- self.nonce = int()
79
- self._enforce_attribute_types()
80
-
81
-
82
- class ITxSignature(TypedClass):
83
- def __init__(self):
84
- self.input_index = int()
85
- self.public_key = PublicKey()
86
- self.subscript = Script()
87
- self.signature = Signature()
88
- self.sig_type = SighashType()
89
- self._enforce_attribute_types()
90
-
91
-
92
- class ISignature(TypedClass):
93
- def __init__(self):
94
- super().__init__()
95
- self.r = int()
96
- self.s = int()
97
- self.i = int()
98
- self.compressed = bool()
99
- self._enforce_attribute_types()
100
-
101
-
102
- class IDigitalSignature(TypedClass):
103
- def __init__(self):
104
- super().__init__()
105
- self.hashbuf = bytearray()
106
- self.endian = EndianType()
107
- self.privkey = IPrivateKey()
108
- self.pubkey = IPublicKey()
109
- self.sig = ISignature()
110
- self.verified = bool()
111
- self._enforce_attribute_types()
112
-
113
-
114
- class IPrivateKey(TypedClass):
115
- compressed: bool
116
- network: Network
117
- bn: int
118
-
119
- def __init__(self):
120
- self.compressed = None
121
- self.network = None
122
- self.bn = None
123
- self._enforce_attribute_types()
124
-
125
-
126
- class IPublicKey(TypedClass):
127
- x: int
128
- y: int
129
- compressed: bool
130
- network: Network
131
-
132
- def __init__(self):
133
- super().__init__()
134
- self.x = None
135
- self.y = None
136
- self.compressed = None
137
- self.network = None
138
- self._enforce_attribute_types()
139
-
140
-
141
- class PrivateKeyDto(TypedClass):
142
- def __init__(self):
143
- super().__init__()
144
- self.compressed = bool()
145
- self.network = str()
146
- self.bn = str()
147
- self._enforce_attribute_types()
148
-
149
-
150
- class PublicKeyDto(TypedClass):
151
- def __init__(self):
152
- super().__init__()
153
- self.x = str()
154
- self.y = str()
155
- self.compressed = bool()
156
- self.network = str()
157
- self._enforce_attribute_types()
158
-
159
-
160
- class AddressDto(TypedClass):
161
- data: bytearray
162
- network: str
163
- type: str
164
-
165
- def __init__(self, data: str = None, network: str = None, type: str = None):
166
- super().__init__()
167
- self.data = None
168
- self.network = None
169
- self.type = None
170
- self._enforce_attribute_types()
171
- if data:
172
- self.data = data
173
- if network:
174
- self.network = network
175
- if type:
176
- self.type = type
177
-
178
-
179
- class HDKeyDto(TypedClass):
180
- def __init__(self):
181
- super().__init__()
182
- self.network = str()
183
- self.depth = int()
184
- self.fingerprint = int()
185
- self.parent_fingerprint = int()
186
- self.child_index = int()
187
- self.chain_code = str()
188
- self.checksum = int()
189
- self._enforce_attribute_types()
190
-
191
-
192
- class HDPrivateKeyDto(HDKeyDto):
193
- def __init__(self):
194
- super().__init__()
195
- self.private_key = str()
196
- self.xprivkey = str()
197
- self._enforce_attribute_types()
198
-
199
-
200
- class HDPublicKeyDto(HDKeyDto):
201
- def __init__(self):
202
- super().__init__()
203
- self.public_key = str()
204
- self.xpubkey = str()
205
- self._enforce_attribute_types()
206
-
207
-
208
- class IHDKey(TypedClass):
209
- def __init__(self):
210
- super().__init__()
211
- self.network = Network()
212
- self.depth = int()
213
- self.parent_fingerprint = bytearray()
214
- self.fingerprint = bytearray()
215
- self.chain_code = bytearray()
216
- self.chain_index = int()
217
- self.checksum = bytearray()
218
- self._enforce_attribute_types()
219
-
220
-
221
- class IHDPrivateKey(IHDKey):
222
- def __init__(self):
223
- super().__init__()
224
- self.private_key = IPrivateKey()
225
- self.public_key = IPublicKey()
226
- self.xprivkey = str()
227
- self._enforce_attribute_types()
228
-
229
-
230
- class IHDPublicKey(IHDKey):
231
- def __init__(self):
232
- super().__init__()
233
- self.public_key = IPublicKey()
234
- self.xpubkey = str()
235
- self._enforce_attribute_types()
236
-
237
-
238
- class HDKeyBuffers(TypedClass):
239
- def __init__(self):
240
- super().__init__()
241
- self.version = bytes()
242
- self.depth = bytes()
243
- self.parent_fingerprint = bytearray()
244
- self.child_index = bytearray()
245
- self.chain_code = bytearray()
246
- self.checksum = bytearray()
247
- self._enforce_attribute_types()
248
-
249
-
250
- class HDPublicKeyBuffers(HDKeyBuffers):
251
- def __init__(self):
252
- super().__init__()
253
- self.public_key = bytearray()
254
- self._enforce_attribute_types()
255
-
256
-
257
- class HDPrivateKeyBuffers(HDKeyBuffers):
258
- def __init__(self):
259
- super().__init__()
260
- self.private_key = bytearray()
261
- self._enforce_attribute_types()
262
-
263
-
264
- class IBlockHeader(TypedClass):
265
- def __init__(self):
266
- super().__init__()
267
- self.hash = str()
268
- self.prev_hash = bytearray()
269
- self.bits = int()
270
- self.ancestor_hash = bytearray()
271
- self.merkle_root = bytearray()
272
- self.tx_filter = bytearray()
273
- self.time = int()
274
- self.height = int()
275
- self.chain_work = bytearray()
276
- self.size = int()
277
- self.tx_count = int()
278
- self.pool_fee = int()
279
- self.utxo_commitment = bytearray()
280
- self.miner_data = bytearray()
281
- self.nonce = bytearray()
282
- self._enforce_attribute_types()
283
-
284
-
285
- class IBlock(TypedClass):
286
- def __init__(self):
287
- super().__init__()
288
- self.header = IBlockHeader()
289
- self.transactions = []
290
- self._enforce_attribute_types()
291
-
292
-
293
- class UTXO(TypedClass):
294
- def __init__(self):
295
- super().__init__()
296
- self.outpoint = str()
297
- self.satoshis = int()
298
- self.amount = int()
299
- self.script_pubkey = Script()
300
- self.address = Address()
301
- self.group_id = Address()
302
- self.group_amount = int()
303
- self.template_data = ScriptTemplateObject()
304
- self._enforce_attribute_types()
305
-
306
-
307
- class SighashComponents(TypedClass):
308
- def __init__(self):
309
- super().__init__()
310
- self.hashPrevouts = bytearray()
311
- self.hashSequence = bytearray()
312
- self.hashInputAmounts = bytearray()
313
- self.hashOutputs = bytearray()
314
- self._enforce_attribute_types()
315
-
316
-
317
- class ScriptTemplateObject(TypedClass):
318
- def __init__(self):
319
- super().__init__()
320
- self.template_script = Script()
321
- self.constraint_script = Script()
322
- self.public_key = PublicKey()
323
- self._enforce_attribute_types()
324
-
325
-
326
- class TxVerifyOptions(TypedClass):
327
- """
328
- Contain a set of flags to skip certain tests:
329
-
330
- * `disableAll`: disable all checks
331
- * `disableIsFullySigned`: disable checking if all inputs are fully signed
332
- * `disableDustOutputs`: disable checking if there are no outputs that are dust amounts
333
- * `disableMoreOutputThanInput`: disable checking if the transaction spends more nexas than the sum of the input amounts
334
- """
335
-
336
- def __init__(self):
337
- super().__init__()
338
- self.disable_all = bool()
339
- self.disable_dust_outputs = bool()
340
- self.disable_is_fully_signed = bool()
341
- self.disable_more_output_than_input = bool()
342
- self._enforce_attribute_types()
343
-
344
-
345
- PrivateKeyVariants = TypeVar(
346
- "PrivateKeyVariants", int, str, bytearray, IPrivateKey, PrivateKeyDto, None
347
- )
348
-
349
- PublicKeyVariants = TypeVar(
350
- "PublicKeyVariants", IPrivateKey, IPublicKey, PublicKeyDto, bytearray, str
351
- )