libnexapy-test 0.1.0__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.
Files changed (56) hide show
  1. libnexapy_test-0.1.0.dist-info/METADATA +104 -0
  2. libnexapy_test-0.1.0.dist-info/RECORD +56 -0
  3. libnexapy_test-0.1.0.dist-info/WHEEL +5 -0
  4. libnexapy_test-0.1.0.dist-info/licenses/LICENCE +22 -0
  5. libnexapy_test-0.1.0.dist-info/top_level.txt +1 -0
  6. src/__init__.py +0 -0
  7. src/common/__init__.py +2 -0
  8. src/common/class_types.py +60 -0
  9. src/common/types.py +351 -0
  10. src/core/address/address.py +380 -0
  11. src/core/address/address_formatter.py +293 -0
  12. src/core/block/block.py +158 -0
  13. src/core/block/block_header.py +257 -0
  14. src/core/grouptoken.py +363 -0
  15. src/core/message.py +131 -0
  16. src/core/network/network.py +118 -0
  17. src/core/network/network_manager.py +131 -0
  18. src/core/script/opcode.py +312 -0
  19. src/core/script/script.py +841 -0
  20. src/core/script/script_factory.py +385 -0
  21. src/core/transaction/input/input.py +134 -0
  22. src/core/transaction/input/public_key_hash.py +47 -0
  23. src/core/transaction/input/public_key_template.py +47 -0
  24. src/core/transaction/input/script_template.py +154 -0
  25. src/core/transaction/output.py +161 -0
  26. src/core/transaction/sighash_type.py +246 -0
  27. src/core/transaction/transaction.py +506 -0
  28. src/core/transaction/tx_builder.py +228 -0
  29. src/core/transaction/tx_signature.py +85 -0
  30. src/core/transaction/tx_signer.py +164 -0
  31. src/core/transaction/unspent_output.py +79 -0
  32. src/crypto/__init__.py +3 -0
  33. src/crypto/curve_utils.py +43 -0
  34. src/crypto/digital_signature.py +73 -0
  35. src/crypto/ecc_fast.py +175 -0
  36. src/crypto/ecdsa.py +310 -0
  37. src/crypto/hash.py +64 -0
  38. src/crypto/libsecp256k1.so.0 +0 -0
  39. src/crypto/ripemd160.py +408 -0
  40. src/crypto/schnorr.py +509 -0
  41. src/crypto/secp256k1.py +223 -0
  42. src/crypto/signature.py +244 -0
  43. src/encoding/base32.py +51 -0
  44. src/encoding/base58.py +165 -0
  45. src/encoding/base58_check.py +92 -0
  46. src/encoding/buffer_reader.py +159 -0
  47. src/encoding/buffer_writer.py +138 -0
  48. src/keys/hd_private_key.py +473 -0
  49. src/keys/hd_public_key.py +417 -0
  50. src/keys/hdkey_utils.py +139 -0
  51. src/keys/private_key.py +340 -0
  52. src/keys/public_key.py +394 -0
  53. src/utils/buffer_utils.py +47 -0
  54. src/utils/common_utils.py +4 -0
  55. src/utils/num_utils.py +81 -0
  56. src/utils/unit_utils.py +78 -0
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: libnexapy_test
3
+ Version: 0.1.0
4
+ Summary: A pure and powerful Python Nexa SDK library (TEST).
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENCE
9
+ Requires-Dist: ecdsa==0.19.2
10
+ Dynamic: license-file
11
+
12
+ # libnexa-py
13
+
14
+
15
+
16
+ ## Getting started
17
+
18
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
19
+
20
+ Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
21
+
22
+ ## Add your files
23
+
24
+ * [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
25
+ * [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
26
+
27
+ ```
28
+ cd existing_repo
29
+ git remote add origin https://gitlab.com/nexa/libnexa-py.git
30
+ git branch -M main
31
+ git push -uf origin main
32
+ ```
33
+
34
+ ## Integrate with your tools
35
+
36
+ * [Set up project integrations](https://gitlab.com/nexa/libnexa-py/-/settings/integrations)
37
+
38
+ ## Collaborate with your team
39
+
40
+ * [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
41
+ * [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
42
+ * [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
43
+ * [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
44
+ * [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
45
+
46
+ ## Test and Deploy
47
+
48
+ Use the built-in continuous integration in GitLab.
49
+
50
+ * [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
51
+ * [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
52
+ * [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
53
+ * [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
54
+ * [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
55
+
56
+ ***
57
+
58
+ # Editing this README
59
+
60
+ When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
61
+
62
+ ## Suggestions for a good README
63
+
64
+ Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
65
+
66
+ ## Name
67
+ Choose a self-explaining name for your project.
68
+
69
+ ## Description
70
+ Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
71
+
72
+ ## Badges
73
+ On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
74
+
75
+ ## Visuals
76
+ Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
77
+
78
+ ## Installation
79
+ Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
80
+
81
+ ## Usage
82
+ Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
83
+
84
+ ## Support
85
+ Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
86
+
87
+ ## Roadmap
88
+ If you have ideas for releases in the future, it is a good idea to list them in the README.
89
+
90
+ ## Contributing
91
+ State if you are open to contributions and what your requirements are for accepting them.
92
+
93
+ For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
94
+
95
+ You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
96
+
97
+ ## Authors and acknowledgment
98
+ Show your appreciation to those who have contributed to the project.
99
+
100
+ ## License
101
+ For open source projects, say how it is licensed.
102
+
103
+ ## Project status
104
+ If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
@@ -0,0 +1,56 @@
1
+ libnexapy_test-0.1.0.dist-info/licenses/LICENCE,sha256=WOPlYoWqWFwSLEkLp2-tIi06Diwr0pUhV1fVGnf7Rno,1108
2
+ src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ src/common/__init__.py,sha256=Btdm3DHmrQYvyyvhbcA9aUau34sZho6orSoU8UV146c,69
4
+ src/common/class_types.py,sha256=J5Wt2ea9tt_NY9F2vpv2n5PURVeY7h-3EVnJJUnS7FU,2468
5
+ src/common/types.py,sha256=nUqtNxHHZJGZOrIEmI-wPxM5K8aVATu4Uswk_OiFnGk,8974
6
+ src/core/grouptoken.py,sha256=CegzdG_eKYYwebWn3ZrmjQ8WF_LI5uM23FqPWh20Fq4,11657
7
+ src/core/message.py,sha256=RAOWSd7vNGpUVmaWyIaEsDM_zwP6kLEICKuGQ5DS42E,4847
8
+ src/core/address/address.py,sha256=5ITtjsN1dAUemB8DQe9WSAKlBmdUtt0X8ABm7fIFRyQ,13627
9
+ src/core/address/address_formatter.py,sha256=tbGXThqJb8atLHy9iXUmrmYJovMcA7TkpsDiVmSDTS4,9913
10
+ src/core/block/block.py,sha256=IaTtaWf0Dm6DksCBEudxIQMIG9HE7ZEJ12Wx3yVdV8I,5378
11
+ src/core/block/block_header.py,sha256=eSqxynkPrGAkFeaZnNNntpHKX4A0lKH4J_q1vNnzuBk,8548
12
+ src/core/network/network.py,sha256=7Op6UPwRc2D32fVBdJP3tsWz8M8aqPa7bTtEZiO07Yc,3935
13
+ src/core/network/network_manager.py,sha256=1m9_8596svO1MPQfcikq9Y4xkKaxrrLXcN62Qm31qJA,4017
14
+ src/core/script/opcode.py,sha256=kp-E_AVlngTkj555MlRePxUrQ6bvIMBtnoO8yMq5j6c,7590
15
+ src/core/script/script.py,sha256=PpdYdoGVRUfXQMXWjZKG0MFCg2g_QaelvDd1mERQbtY,31142
16
+ src/core/script/script_factory.py,sha256=gaEqcSekceXuauZKFzjeXirQZkobBhBSci703Lxyb80,15283
17
+ src/core/transaction/output.py,sha256=cfbCkKLAO4SNCebFGWDZzHs7ccr2uFbspvp465T5QbI,5644
18
+ src/core/transaction/sighash_type.py,sha256=6_OsUROrBn-1xixLrY7ZNQum5LfNmWrQtfjgMyPC984,8108
19
+ src/core/transaction/transaction.py,sha256=6AJjzHN1LYhk-z2UvCsf8Pe-pTzs3yVKzrn0FXR85K0,18592
20
+ src/core/transaction/tx_builder.py,sha256=gmHNXCh4vfdzvFi1hpTQXefYXg8tN9g3hJT9FkDV7K8,8405
21
+ src/core/transaction/tx_signature.py,sha256=N_i-0CYqS4PNFhzjttylq_9P3z1n5YSu3AJh3r008hs,3305
22
+ src/core/transaction/tx_signer.py,sha256=W_4zE5eq0uNG2gFUgyduBSjR1RYx3DSdFbdaly9Pjqg,7516
23
+ src/core/transaction/unspent_output.py,sha256=Y03QsB6uMtcQsvEbV8XsN877QkQyefPjCfW8paxZek8,3214
24
+ src/core/transaction/input/input.py,sha256=4ULhMwkreVUzqVcp1EI_hNmjvc8sN1qXihwu8G7q-Oo,4554
25
+ src/core/transaction/input/public_key_hash.py,sha256=RF2j-r1JsRIyYfSNTeVzJdsBsY5hnddv-bEo9iNA3KM,1601
26
+ src/core/transaction/input/public_key_template.py,sha256=Ycoaq8-NnYNPzZwTqELeauuILj47kzSZE5-i1CWX_3Y,1733
27
+ src/core/transaction/input/script_template.py,sha256=VhUII4V65Pb6bwg7R4ORT9kuF1nkkS2tQ91EDpsEbbU,6340
28
+ src/crypto/__init__.py,sha256=W3jXLndRhFMwLDptLIY7yn7c1QVJkUeZ5m_QxWaTx_o,98
29
+ src/crypto/curve_utils.py,sha256=j35QGjSHxTd57Iv6wijbfmqBTuwIjGZmZved5qen2qo,1477
30
+ src/crypto/digital_signature.py,sha256=jDgpJOBqW7kJut-rrMR5BTPJKpMo3fXx1sgcpj9Ct1k,2468
31
+ src/crypto/ecc_fast.py,sha256=RPfyF6lz-_B3pd5HWl_odb1Qx2xXQLJgvPmbWDyn6HU,7065
32
+ src/crypto/ecdsa.py,sha256=MUKBCony_GDf57weYIfkmDT_vLC9aIpphB5azYEUP-0,10006
33
+ src/crypto/hash.py,sha256=yA0XUHaDoWs8uE1D7CMtOq877LlnEU5VPRY3Xi30vdc,2708
34
+ src/crypto/libsecp256k1.so.0,sha256=kotcYjYZUVETnPS2W25rBechEvCQ4Kt-OtqrCO1YfGc,524160
35
+ src/crypto/ripemd160.py,sha256=nhtWiUieScWOTaS7qRkVIm6nazjp69lpKTbfD-NH_Ko,14059
36
+ src/crypto/schnorr.py,sha256=cSboJIhAUjsgALKpuYNiyEaQhl9dNUfCYNE5Oy8vVSM,18905
37
+ src/crypto/secp256k1.py,sha256=3xZNGcqOkmNtYKMiFEtaM7QG8311che1vRnwgMwTLgM,8076
38
+ src/crypto/signature.py,sha256=15arPj1JS091Tw_NA-ozmaLCmKGmkDTYiblNAtiY3eQ,7454
39
+ src/encoding/base32.py,sha256=lztG51ZCydw1ePqtnRRjFmH6OJXyBcGA5HYbpUXb2eA,1712
40
+ src/encoding/base58.py,sha256=9gB3jhyGBVQqOVi5enlbRSCxlD1bINWLGTqisUA_MW4,4340
41
+ src/encoding/base58_check.py,sha256=w629H44MSzc1WstK5tyjxrDk7rvo8WsxD6gBkNGQBA8,2698
42
+ src/encoding/buffer_reader.py,sha256=H3cWMv3re_g2BVjdXE5BT2UKcLGApDRU26duy7WA0EM,4958
43
+ src/encoding/buffer_writer.py,sha256=ToJBNJ9322Pny19L1zUtMhdko5Baw4uvoNVomqf_7OY,4257
44
+ src/keys/hd_private_key.py,sha256=qkwtUJStYcVHXw0EHZoovO7WvRQBYHWM3VYvr3k0j6I,17923
45
+ src/keys/hd_public_key.py,sha256=VGLodk8wHyYH4ok2LqU-1lQkLxI3RfD7l_7X0IFnrx0,15782
46
+ src/keys/hdkey_utils.py,sha256=MO2fYnFMaQwUhOOw8n0eGOM0gN7ANNdq1hgXkyx69tk,4711
47
+ src/keys/private_key.py,sha256=fkSdRgQcXz0aCYDLlRuTNANwYE0AVZn_p2U_jamqnCA,11320
48
+ src/keys/public_key.py,sha256=1ViOfBF80psQ7pP8kJ4t-bnmd4XhdMHMeiMD1QZdcPM,13876
49
+ src/utils/buffer_utils.py,sha256=H7jQFJB0ZW9PAjojoDs_ZhZBVOymJ1snkn0-UjiNm4Q,1387
50
+ src/utils/common_utils.py,sha256=1RcUWBRXBNJ1BSGaHQNrJbDFKjXDlYNuNaPMebWASl8,207
51
+ src/utils/num_utils.py,sha256=fpRVGxGktjkOcWE8U1d0wGhXW_zqLZLZRzI258xCZmU,3097
52
+ src/utils/unit_utils.py,sha256=lnOHmhzZskWx1yossiRXMJ3XPNsxa7rm03jtmhrhS9I,2336
53
+ libnexapy_test-0.1.0.dist-info/METADATA,sha256=3sERyK9RGKbpu468iNz3Wj7RaXtOpFsNq1mZov4JBYA,6288
54
+ libnexapy_test-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
55
+ libnexapy_test-0.1.0.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
56
+ libnexapy_test-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,22 @@
1
+ The MIT Licence (MIT)
2
+
3
+ Copyright (c) 2026-Present The Bitcoin Unlimited developers
4
+
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicence, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ src
src/__init__.py ADDED
File without changes
src/common/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from types import *
2
+ from .class_types import FrozenClass, TypedClass
@@ -0,0 +1,60 @@
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
src/common/types.py ADDED
@@ -0,0 +1,351 @@
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
+ )