libnexapy-test 0.2.0__tar.gz → 0.4.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_test-0.2.0/libnexapy_test.egg-info → libnexapy_test-0.4.0}/PKG-INFO +1 -1
- libnexapy_test-0.4.0/libnexapy_test/__init__.py +0 -0
- libnexapy_test-0.4.0/libnexapy_test/common/__init__.py +2 -0
- libnexapy_test-0.4.0/libnexapy_test/common/class_types.py +60 -0
- libnexapy_test-0.4.0/libnexapy_test/common/types.py +351 -0
- libnexapy_test-0.4.0/libnexapy_test/core/address/address.py +380 -0
- libnexapy_test-0.4.0/libnexapy_test/core/address/address_formatter.py +293 -0
- libnexapy_test-0.4.0/libnexapy_test/core/block/block.py +158 -0
- libnexapy_test-0.4.0/libnexapy_test/core/block/block_header.py +257 -0
- libnexapy_test-0.4.0/libnexapy_test/core/grouptoken.py +363 -0
- libnexapy_test-0.4.0/libnexapy_test/core/message.py +131 -0
- libnexapy_test-0.4.0/libnexapy_test/core/network/network.py +118 -0
- libnexapy_test-0.4.0/libnexapy_test/core/network/network_manager.py +131 -0
- libnexapy_test-0.4.0/libnexapy_test/core/script/opcode.py +312 -0
- libnexapy_test-0.4.0/libnexapy_test/core/script/script.py +841 -0
- libnexapy_test-0.4.0/libnexapy_test/core/script/script_factory.py +385 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/input/input.py +134 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/input/public_key_hash.py +47 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/input/public_key_template.py +47 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/input/script_template.py +154 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/output.py +161 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/sighash_type.py +246 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/transaction.py +506 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/tx_builder.py +228 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/tx_signature.py +85 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/tx_signer.py +164 -0
- libnexapy_test-0.4.0/libnexapy_test/core/transaction/unspent_output.py +79 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/__init__.py +3 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/curve_utils.py +43 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/digital_signature.py +73 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/ecc_fast.py +175 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/ecdsa.py +310 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/hash.py +64 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/ripemd160.py +408 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/schnorr.py +509 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/secp256k1.py +223 -0
- libnexapy_test-0.4.0/libnexapy_test/crypto/signature.py +244 -0
- libnexapy_test-0.4.0/libnexapy_test/encoding/base32.py +51 -0
- libnexapy_test-0.4.0/libnexapy_test/encoding/base58.py +165 -0
- libnexapy_test-0.4.0/libnexapy_test/encoding/base58_check.py +92 -0
- libnexapy_test-0.4.0/libnexapy_test/encoding/buffer_reader.py +159 -0
- libnexapy_test-0.4.0/libnexapy_test/encoding/buffer_writer.py +138 -0
- libnexapy_test-0.4.0/libnexapy_test/keys/hd_private_key.py +473 -0
- libnexapy_test-0.4.0/libnexapy_test/keys/hd_public_key.py +417 -0
- libnexapy_test-0.4.0/libnexapy_test/keys/hdkey_utils.py +139 -0
- libnexapy_test-0.4.0/libnexapy_test/keys/private_key.py +340 -0
- libnexapy_test-0.4.0/libnexapy_test/keys/public_key.py +394 -0
- libnexapy_test-0.4.0/libnexapy_test/utils/buffer_utils.py +47 -0
- libnexapy_test-0.4.0/libnexapy_test/utils/common_utils.py +4 -0
- libnexapy_test-0.4.0/libnexapy_test/utils/num_utils.py +81 -0
- libnexapy_test-0.4.0/libnexapy_test/utils/unit_utils.py +78 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0/libnexapy_test.egg-info}/PKG-INFO +1 -1
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/libnexapy_test.egg-info/SOURCES.txt +50 -0
- libnexapy_test-0.4.0/libnexapy_test.egg-info/top_level.txt +1 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/pyproject.toml +3 -3
- libnexapy_test-0.2.0/libnexapy_test.egg-info/top_level.txt +0 -1
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/LICENCE +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/MANIFEST.in +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/README.md +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/libnexapy_test.egg-info/dependency_links.txt +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/libnexapy_test.egg-info/requires.txt +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/COPYING +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/Makefile.am +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/README.md +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/autogen.sh +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/build-aux/m4/ax_jni_include_dir.m4 +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/build-aux/m4/bitcoin_secp.m4 +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/configure.ac +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/contrib/lax_der_parsing.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/contrib/lax_der_parsing.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/contrib/lax_der_privatekey_parsing.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/contrib/lax_der_privatekey_parsing.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1_ecdh.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1_multiset.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1_preallocated.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1_recovery.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/include/secp256k1_schnorr.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/libsecp256k1.pc.in +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/asm/field_10x26_arm.s +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/basic-config.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_ecdh.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_ecmult.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_internal.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_multiset.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_recover.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_sign.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/bench_verify.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecdsa.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecdsa_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/eckey.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/eckey_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult_const.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult_const_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult_gen.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult_gen_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/ecmult_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_10x26.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_10x26_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_5x52.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_5x52_asm_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_5x52_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_5x52_int128_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/field_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/gen_context.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/group.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/group_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/hash.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/hash_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/java/org_bitcoin_Secp256k1Context.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/java/org_bitcoin_Secp256k1Context.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/ecdh/Makefile.am.include +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/ecdh/main_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/ecdh/tests_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/multiset/Makefile.am.include +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/multiset/main_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/multiset/tests_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/recovery/Makefile.am.include +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/recovery/main_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/recovery/tests_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/schnorr/Makefile.am.include +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/schnorr/main_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/schnorr/schnorr.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/schnorr/schnorr_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/modules/schnorr/tests_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/num.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/num_gmp.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/num_gmp_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/num_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_4x64.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_4x64_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_8x32.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_8x32_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_low.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scalar_low_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scratch.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/scratch_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/secp256k1.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/testrand.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/testrand_impl.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/tests.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/tests_exhaustive.c +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/secp256k1/src/util.h +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/setup.cfg +0 -0
- {libnexapy_test-0.2.0 → libnexapy_test-0.4.0}/setup.py +0 -0
|
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 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
|
+
)
|