libnexapy 0.1.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.
- libnexapy-0.1.0/LICENCE +22 -0
- libnexapy-0.1.0/MANIFEST.in +3 -0
- libnexapy-0.1.0/PKG-INFO +43 -0
- libnexapy-0.1.0/README.md +32 -0
- libnexapy-0.1.0/libnexapy/__init__.py +0 -0
- libnexapy-0.1.0/libnexapy/common/__init__.py +2 -0
- libnexapy-0.1.0/libnexapy/common/class_types.py +60 -0
- libnexapy-0.1.0/libnexapy/common/types.py +351 -0
- libnexapy-0.1.0/libnexapy/core/address/address.py +380 -0
- libnexapy-0.1.0/libnexapy/core/address/address_formatter.py +293 -0
- libnexapy-0.1.0/libnexapy/core/block/block.py +158 -0
- libnexapy-0.1.0/libnexapy/core/block/block_header.py +257 -0
- libnexapy-0.1.0/libnexapy/core/grouptoken.py +363 -0
- libnexapy-0.1.0/libnexapy/core/message.py +131 -0
- libnexapy-0.1.0/libnexapy/core/network/network.py +118 -0
- libnexapy-0.1.0/libnexapy/core/network/network_manager.py +131 -0
- libnexapy-0.1.0/libnexapy/core/script/opcode.py +312 -0
- libnexapy-0.1.0/libnexapy/core/script/script.py +841 -0
- libnexapy-0.1.0/libnexapy/core/script/script_factory.py +385 -0
- libnexapy-0.1.0/libnexapy/core/transaction/input/input.py +134 -0
- libnexapy-0.1.0/libnexapy/core/transaction/input/public_key_hash.py +47 -0
- libnexapy-0.1.0/libnexapy/core/transaction/input/public_key_template.py +47 -0
- libnexapy-0.1.0/libnexapy/core/transaction/input/script_template.py +154 -0
- libnexapy-0.1.0/libnexapy/core/transaction/output.py +161 -0
- libnexapy-0.1.0/libnexapy/core/transaction/sighash_type.py +246 -0
- libnexapy-0.1.0/libnexapy/core/transaction/transaction.py +506 -0
- libnexapy-0.1.0/libnexapy/core/transaction/tx_builder.py +228 -0
- libnexapy-0.1.0/libnexapy/core/transaction/tx_signature.py +85 -0
- libnexapy-0.1.0/libnexapy/core/transaction/tx_signer.py +164 -0
- libnexapy-0.1.0/libnexapy/core/transaction/unspent_output.py +79 -0
- libnexapy-0.1.0/libnexapy/crypto/__init__.py +3 -0
- libnexapy-0.1.0/libnexapy/crypto/curve_utils.py +43 -0
- libnexapy-0.1.0/libnexapy/crypto/digital_signature.py +73 -0
- libnexapy-0.1.0/libnexapy/crypto/ecc_fast.py +175 -0
- libnexapy-0.1.0/libnexapy/crypto/ecdsa.py +310 -0
- libnexapy-0.1.0/libnexapy/crypto/hash.py +64 -0
- libnexapy-0.1.0/libnexapy/crypto/ripemd160.py +408 -0
- libnexapy-0.1.0/libnexapy/crypto/schnorr.py +509 -0
- libnexapy-0.1.0/libnexapy/crypto/secp256k1.py +223 -0
- libnexapy-0.1.0/libnexapy/crypto/signature.py +244 -0
- libnexapy-0.1.0/libnexapy/encoding/base32.py +51 -0
- libnexapy-0.1.0/libnexapy/encoding/base58.py +165 -0
- libnexapy-0.1.0/libnexapy/encoding/base58_check.py +92 -0
- libnexapy-0.1.0/libnexapy/encoding/buffer_reader.py +159 -0
- libnexapy-0.1.0/libnexapy/encoding/buffer_writer.py +138 -0
- libnexapy-0.1.0/libnexapy/keys/hd_private_key.py +473 -0
- libnexapy-0.1.0/libnexapy/keys/hd_public_key.py +417 -0
- libnexapy-0.1.0/libnexapy/keys/hdkey_utils.py +139 -0
- libnexapy-0.1.0/libnexapy/keys/private_key.py +340 -0
- libnexapy-0.1.0/libnexapy/keys/public_key.py +394 -0
- libnexapy-0.1.0/libnexapy/utils/buffer_utils.py +47 -0
- libnexapy-0.1.0/libnexapy/utils/common_utils.py +4 -0
- libnexapy-0.1.0/libnexapy/utils/num_utils.py +81 -0
- libnexapy-0.1.0/libnexapy/utils/unit_utils.py +78 -0
- libnexapy-0.1.0/libnexapy.egg-info/PKG-INFO +43 -0
- libnexapy-0.1.0/libnexapy.egg-info/SOURCES.txt +162 -0
- libnexapy-0.1.0/libnexapy.egg-info/dependency_links.txt +1 -0
- libnexapy-0.1.0/libnexapy.egg-info/requires.txt +1 -0
- libnexapy-0.1.0/libnexapy.egg-info/top_level.txt +1 -0
- libnexapy-0.1.0/pyproject.toml +34 -0
- libnexapy-0.1.0/secp256k1/.gitignore +50 -0
- libnexapy-0.1.0/secp256k1/COPYING +19 -0
- libnexapy-0.1.0/secp256k1/Makefile.am +186 -0
- libnexapy-0.1.0/secp256k1/README.md +112 -0
- libnexapy-0.1.0/secp256k1/SECURITY.md +15 -0
- libnexapy-0.1.0/secp256k1/TODO +3 -0
- libnexapy-0.1.0/secp256k1/autogen.sh +3 -0
- libnexapy-0.1.0/secp256k1/build-aux/m4/ax_jni_include_dir.m4 +145 -0
- libnexapy-0.1.0/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 +125 -0
- libnexapy-0.1.0/secp256k1/build-aux/m4/bitcoin_secp.m4 +68 -0
- libnexapy-0.1.0/secp256k1/configure.ac +616 -0
- libnexapy-0.1.0/secp256k1/contrib/lax_der_parsing.c +150 -0
- libnexapy-0.1.0/secp256k1/contrib/lax_der_parsing.h +91 -0
- libnexapy-0.1.0/secp256k1/contrib/lax_der_privatekey_parsing.c +113 -0
- libnexapy-0.1.0/secp256k1/contrib/lax_der_privatekey_parsing.h +90 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1.h +708 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1_ecdh.h +62 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1_multiset.h +110 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1_preallocated.h +128 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1_recovery.h +110 -0
- libnexapy-0.1.0/secp256k1/include/secp256k1_schnorr.h +57 -0
- libnexapy-0.1.0/secp256k1/libsecp256k1.pc.in +13 -0
- libnexapy-0.1.0/secp256k1/obj/.gitignore +0 -0
- libnexapy-0.1.0/secp256k1/sage/group_prover.sage +322 -0
- libnexapy-0.1.0/secp256k1/sage/secp256k1.sage +306 -0
- libnexapy-0.1.0/secp256k1/sage/weierstrass_prover.sage +264 -0
- libnexapy-0.1.0/secp256k1/src/asm/field_10x26_arm.s +913 -0
- libnexapy-0.1.0/secp256k1/src/basic-config.h +38 -0
- libnexapy-0.1.0/secp256k1/src/bench.h +124 -0
- libnexapy-0.1.0/secp256k1/src/bench_ecdh.c +54 -0
- libnexapy-0.1.0/secp256k1/src/bench_ecmult.c +207 -0
- libnexapy-0.1.0/secp256k1/src/bench_internal.c +379 -0
- libnexapy-0.1.0/secp256k1/src/bench_multiset.c +53 -0
- libnexapy-0.1.0/secp256k1/src/bench_recover.c +60 -0
- libnexapy-0.1.0/secp256k1/src/bench_sign.c +80 -0
- libnexapy-0.1.0/secp256k1/src/bench_verify.c +140 -0
- libnexapy-0.1.0/secp256k1/src/ecdsa.h +21 -0
- libnexapy-0.1.0/secp256k1/src/ecdsa_impl.h +319 -0
- libnexapy-0.1.0/secp256k1/src/eckey.h +25 -0
- libnexapy-0.1.0/secp256k1/src/eckey_impl.h +100 -0
- libnexapy-0.1.0/secp256k1/src/ecmult.h +48 -0
- libnexapy-0.1.0/secp256k1/src/ecmult_const.h +20 -0
- libnexapy-0.1.0/secp256k1/src/ecmult_const_impl.h +264 -0
- libnexapy-0.1.0/secp256k1/src/ecmult_gen.h +50 -0
- libnexapy-0.1.0/secp256k1/src/ecmult_gen_impl.h +214 -0
- libnexapy-0.1.0/secp256k1/src/ecmult_impl.h +1216 -0
- libnexapy-0.1.0/secp256k1/src/field.h +134 -0
- libnexapy-0.1.0/secp256k1/src/field_10x26.h +50 -0
- libnexapy-0.1.0/secp256k1/src/field_10x26_impl.h +1162 -0
- libnexapy-0.1.0/secp256k1/src/field_5x52.h +49 -0
- libnexapy-0.1.0/secp256k1/src/field_5x52_asm_impl.h +502 -0
- libnexapy-0.1.0/secp256k1/src/field_5x52_impl.h +496 -0
- libnexapy-0.1.0/secp256k1/src/field_5x52_int128_impl.h +279 -0
- libnexapy-0.1.0/secp256k1/src/field_impl.h +318 -0
- libnexapy-0.1.0/secp256k1/src/gen_context.c +87 -0
- libnexapy-0.1.0/secp256k1/src/group.h +141 -0
- libnexapy-0.1.0/secp256k1/src/group_impl.h +708 -0
- libnexapy-0.1.0/secp256k1/src/hash.h +41 -0
- libnexapy-0.1.0/secp256k1/src/hash_impl.h +283 -0
- libnexapy-0.1.0/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java +514 -0
- libnexapy-0.1.0/secp256k1/src/java/org/bitcoin/NativeSecp256k1Test.java +417 -0
- libnexapy-0.1.0/secp256k1/src/java/org/bitcoin/NativeSecp256k1Util.java +51 -0
- libnexapy-0.1.0/secp256k1/src/java/org/bitcoin/Secp256k1Context.java +51 -0
- libnexapy-0.1.0/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c +431 -0
- libnexapy-0.1.0/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h +135 -0
- libnexapy-0.1.0/secp256k1/src/java/org_bitcoin_Secp256k1Context.c +15 -0
- libnexapy-0.1.0/secp256k1/src/java/org_bitcoin_Secp256k1Context.h +22 -0
- libnexapy-0.1.0/secp256k1/src/modules/ecdh/Makefile.am.include +8 -0
- libnexapy-0.1.0/secp256k1/src/modules/ecdh/main_impl.h +67 -0
- libnexapy-0.1.0/secp256k1/src/modules/ecdh/tests_impl.h +132 -0
- libnexapy-0.1.0/secp256k1/src/modules/multiset/Makefile.am.include +8 -0
- libnexapy-0.1.0/secp256k1/src/modules/multiset/README.md +82 -0
- libnexapy-0.1.0/secp256k1/src/modules/multiset/main_impl.h +210 -0
- libnexapy-0.1.0/secp256k1/src/modules/multiset/tests_impl.h +347 -0
- libnexapy-0.1.0/secp256k1/src/modules/recovery/Makefile.am.include +8 -0
- libnexapy-0.1.0/secp256k1/src/modules/recovery/main_impl.h +194 -0
- libnexapy-0.1.0/secp256k1/src/modules/recovery/tests_impl.h +392 -0
- libnexapy-0.1.0/secp256k1/src/modules/schnorr/Makefile.am.include +5 -0
- libnexapy-0.1.0/secp256k1/src/modules/schnorr/main_impl.h +63 -0
- libnexapy-0.1.0/secp256k1/src/modules/schnorr/schnorr.h +64 -0
- libnexapy-0.1.0/secp256k1/src/modules/schnorr/schnorr_impl.h +254 -0
- libnexapy-0.1.0/secp256k1/src/modules/schnorr/tests_impl.h +522 -0
- libnexapy-0.1.0/secp256k1/src/num.h +74 -0
- libnexapy-0.1.0/secp256k1/src/num_gmp.h +20 -0
- libnexapy-0.1.0/secp256k1/src/num_gmp_impl.h +288 -0
- libnexapy-0.1.0/secp256k1/src/num_impl.h +24 -0
- libnexapy-0.1.0/secp256k1/src/scalar.h +110 -0
- libnexapy-0.1.0/secp256k1/src/scalar_4x64.h +19 -0
- libnexapy-0.1.0/secp256k1/src/scalar_4x64_impl.h +949 -0
- libnexapy-0.1.0/secp256k1/src/scalar_8x32.h +19 -0
- libnexapy-0.1.0/secp256k1/src/scalar_8x32_impl.h +721 -0
- libnexapy-0.1.0/secp256k1/src/scalar_impl.h +333 -0
- libnexapy-0.1.0/secp256k1/src/scalar_low.h +15 -0
- libnexapy-0.1.0/secp256k1/src/scalar_low_impl.h +117 -0
- libnexapy-0.1.0/secp256k1/src/scratch.h +42 -0
- libnexapy-0.1.0/secp256k1/src/scratch_impl.h +88 -0
- libnexapy-0.1.0/secp256k1/src/secp256k1.c +699 -0
- libnexapy-0.1.0/secp256k1/src/testrand.h +38 -0
- libnexapy-0.1.0/secp256k1/src/testrand_impl.h +110 -0
- libnexapy-0.1.0/secp256k1/src/tests.c +5327 -0
- libnexapy-0.1.0/secp256k1/src/tests_exhaustive.c +511 -0
- libnexapy-0.1.0/secp256k1/src/util.h +167 -0
- libnexapy-0.1.0/setup.cfg +4 -0
- libnexapy-0.1.0/setup.py +151 -0
libnexapy-0.1.0/LICENCE
ADDED
|
@@ -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.
|
libnexapy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: libnexapy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A pure and powerful Python Nexa SDK library.
|
|
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 Python
|
|
13
|
+
|
|
14
|
+
**A pure and powerful Python Nexa SDK library.**
|
|
15
|
+
|
|
16
|
+
## Principles
|
|
17
|
+
|
|
18
|
+
Nexa is another powerful peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Nexa network allows for highly resilient nexa infrastructure, and the developer community needs reliable, open-source tools to implement Nexa apps and services.
|
|
19
|
+
|
|
20
|
+
## Get Started
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pip3 install libnexapy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Development & Tests
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
git clone https://gitlab.com/nexa/libnexa-py.git
|
|
30
|
+
cd libnexa-py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Run the linter
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
./run-linter.sh
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Run all the tests:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
./run-tests.sh
|
|
43
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Libnexa Python
|
|
2
|
+
|
|
3
|
+
**A pure and powerful Python Nexa SDK library.**
|
|
4
|
+
|
|
5
|
+
## Principles
|
|
6
|
+
|
|
7
|
+
Nexa is another powerful peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Nexa network allows for highly resilient nexa infrastructure, and the developer community needs reliable, open-source tools to implement Nexa apps and services.
|
|
8
|
+
|
|
9
|
+
## Get Started
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip3 install libnexapy
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Development & Tests
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
git clone https://gitlab.com/nexa/libnexa-py.git
|
|
19
|
+
cd libnexa-py
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Run the linter
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
./run-linter.sh
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Run all the tests:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
./run-tests.sh
|
|
32
|
+
```
|
|
File without changes
|
|
@@ -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
|
|
@@ -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 libnexapy.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
|
+
)
|