symbol-sdk-python 3.2.2__tar.gz → 3.3.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.
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/PKG-INFO +18 -16
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/README.md +9 -9
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/pyproject.toml +6 -6
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/BaseValue.py +4 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/ByteArray.py +4 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/Network.py +1 -1
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/facade/NemFacade.py +9 -7
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/facade/SymbolFacade.py +27 -12
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nc/__init__.py +463 -24
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/sc/__init__.py +880 -4
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/AccountDescriptorRepository.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/ArrayHelpers.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/Bip32.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/BlockchainSettings.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/BufferReader.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/BufferWriter.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/Cipher.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/CodeWordsEncoder.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/CryptoTypes.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/DiceMnemonicGenerator.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/NetworkTimestamp.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/NodeDescriptorRepository.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/Ordered.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/PrivateKeyStorage.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/QrSignatureStorage.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/QrStorage.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/RuleBasedTransactionFactory.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/TransactionDescriptorProcessor.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/Transforms.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/__init__.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/external/__init__.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/external/ed25519.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/facade/BatchOperations.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/facade/__init__.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/impl/CipherHelpers.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/impl/__init__.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/KeyPair.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/MessageEncoder.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/Network.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/TransactionFactory.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/nem/__init__.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/ripemd160.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/IdGenerator.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/KeyPair.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/Merkle.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/MessageEncoder.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/Metadata.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/Network.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/SharedKey.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/TransactionFactory.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/VotingKeysGenerator.py +0 -0
- {symbol_sdk_python-3.2.2 → symbol_sdk_python-3.3.0}/symbolchain/symbol/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: symbol-sdk-python
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Summary: Symbol SDK
|
|
5
5
|
Home-page: https://github.com/symbol/symbol/tree/main/sdk/python
|
|
6
6
|
License: MIT
|
|
@@ -9,19 +9,21 @@ Author: Symbol Contributors
|
|
|
9
9
|
Author-email: contributors@symbol.dev
|
|
10
10
|
Maintainer: Symbol Contributors
|
|
11
11
|
Maintainer-email: contributors@symbol.dev
|
|
12
|
-
Requires-Python: >=3.9,<4.0
|
|
12
|
+
Requires-Python: >=3.9.2,<4.0.0
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Requires-Dist: cryptography (>=46.0.1,<46.1.0)
|
|
19
21
|
Requires-Dist: mnemonic (>=0.20,<1.0)
|
|
20
|
-
Requires-Dist: pillow (>=
|
|
21
|
-
Requires-Dist: pynacl (>=1.
|
|
22
|
+
Requires-Dist: pillow (>=11.3.0,<11.4.0)
|
|
23
|
+
Requires-Dist: pynacl (>=1.6.0,<1.7.0)
|
|
22
24
|
Requires-Dist: pyyaml (>=6.0.1,<6.1.0)
|
|
23
25
|
Requires-Dist: pyzbar (>=0.1.9,<0.2.0)
|
|
24
|
-
Requires-Dist: qrcode (>=
|
|
26
|
+
Requires-Dist: qrcode (>=8.0,<9.0)
|
|
25
27
|
Requires-Dist: ripemd-hash (>=1.0.1,<1.1.0)
|
|
26
28
|
Requires-Dist: safe-pysha3 (>=1.0.4,<1.1.0)
|
|
27
29
|
Project-URL: Repository, https://github.com/symbol/symbol/tree/main/sdk/python
|
|
@@ -31,12 +33,12 @@ Description-Content-Type: text/markdown
|
|
|
31
33
|
|
|
32
34
|
[![lint][sdk-python-lint]][sdk-python-job] [![test][sdk-python-test]][sdk-python-job] [![vectors][sdk-python-vectors]][sdk-python-job] [![][sdk-python-cov]][sdk-python-cov-link] [![][sdk-python-package]][sdk-python-package-link]
|
|
33
35
|
|
|
34
|
-
[sdk-python-job]: https://jenkins.
|
|
35
|
-
[sdk-python-lint]: https://jenkins.
|
|
36
|
-
[sdk-python-build]: https://jenkins.
|
|
37
|
-
[sdk-python-test]: https://jenkins.
|
|
38
|
-
[sdk-python-examples]: https://jenkins.
|
|
39
|
-
[sdk-python-vectors]: https://jenkins.
|
|
36
|
+
[sdk-python-job]: https://jenkins.symbolsyndicate.us/blue/organizations/jenkins/Symbol%2Fgenerated%2Fsymbol%2Fpython/activity?branch=dev
|
|
37
|
+
[sdk-python-lint]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-lint
|
|
38
|
+
[sdk-python-build]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-build
|
|
39
|
+
[sdk-python-test]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-test
|
|
40
|
+
[sdk-python-examples]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-examples
|
|
41
|
+
[sdk-python-vectors]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-vectors
|
|
40
42
|
[sdk-python-cov]: https://codecov.io/gh/symbol/symbol/branch/dev/graph/badge.svg?token=SSYYBMK0M7&flag=sdk-python
|
|
41
43
|
[sdk-python-cov-link]: https://codecov.io/gh/symbol/symbol/tree/dev/sdk/python
|
|
42
44
|
[sdk-python-package]: https://img.shields.io/pypi/v/symbol-sdk-python
|
|
@@ -62,9 +64,9 @@ facade = SymbolFacade('testnet')
|
|
|
62
64
|
_NEM_
|
|
63
65
|
```python
|
|
64
66
|
from symbolchain.CryptoTypes import PrivateKey
|
|
65
|
-
from symbolchain.facade.
|
|
67
|
+
from symbolchain.facade.NemFacade import NemFacade
|
|
66
68
|
|
|
67
|
-
facade =
|
|
69
|
+
facade = NemFacade('testnet')
|
|
68
70
|
````
|
|
69
71
|
|
|
70
72
|
Second, describe the transaction using a Python dictionary. For example, a transfer transaction can be described as follows:
|
|
@@ -103,7 +105,7 @@ Third, sign the transaction and attach the signature:
|
|
|
103
105
|
private_key = PrivateKey('EDB671EB741BD676969D8A035271D1EE5E75DF33278083D877F23615EB839FEC')
|
|
104
106
|
signature = facade.sign_transaction(facade.KeyPair(private_key), transaction)
|
|
105
107
|
|
|
106
|
-
json_payload = facade.
|
|
108
|
+
json_payload = facade.transaction_factory.attach_signature(transaction, signature)
|
|
107
109
|
```
|
|
108
110
|
|
|
109
111
|
Finally, send the payload to the desired network using the specified node endpoint:
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[![lint][sdk-python-lint]][sdk-python-job] [![test][sdk-python-test]][sdk-python-job] [![vectors][sdk-python-vectors]][sdk-python-job] [![][sdk-python-cov]][sdk-python-cov-link] [![][sdk-python-package]][sdk-python-package-link]
|
|
4
4
|
|
|
5
|
-
[sdk-python-job]: https://jenkins.
|
|
6
|
-
[sdk-python-lint]: https://jenkins.
|
|
7
|
-
[sdk-python-build]: https://jenkins.
|
|
8
|
-
[sdk-python-test]: https://jenkins.
|
|
9
|
-
[sdk-python-examples]: https://jenkins.
|
|
10
|
-
[sdk-python-vectors]: https://jenkins.
|
|
5
|
+
[sdk-python-job]: https://jenkins.symbolsyndicate.us/blue/organizations/jenkins/Symbol%2Fgenerated%2Fsymbol%2Fpython/activity?branch=dev
|
|
6
|
+
[sdk-python-lint]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-lint
|
|
7
|
+
[sdk-python-build]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-build
|
|
8
|
+
[sdk-python-test]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-test
|
|
9
|
+
[sdk-python-examples]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-examples
|
|
10
|
+
[sdk-python-vectors]: https://jenkins.symbolsyndicate.us/buildStatus/icon?job=Symbol%2Fgenerated%2Fsymbol%2Fpython%2Fdev%2F&config=sdk-python-vectors
|
|
11
11
|
[sdk-python-cov]: https://codecov.io/gh/symbol/symbol/branch/dev/graph/badge.svg?token=SSYYBMK0M7&flag=sdk-python
|
|
12
12
|
[sdk-python-cov-link]: https://codecov.io/gh/symbol/symbol/tree/dev/sdk/python
|
|
13
13
|
[sdk-python-package]: https://img.shields.io/pypi/v/symbol-sdk-python
|
|
@@ -33,9 +33,9 @@ facade = SymbolFacade('testnet')
|
|
|
33
33
|
_NEM_
|
|
34
34
|
```python
|
|
35
35
|
from symbolchain.CryptoTypes import PrivateKey
|
|
36
|
-
from symbolchain.facade.
|
|
36
|
+
from symbolchain.facade.NemFacade import NemFacade
|
|
37
37
|
|
|
38
|
-
facade =
|
|
38
|
+
facade = NemFacade('testnet')
|
|
39
39
|
````
|
|
40
40
|
|
|
41
41
|
Second, describe the transaction using a Python dictionary. For example, a transfer transaction can be described as follows:
|
|
@@ -74,7 +74,7 @@ Third, sign the transaction and attach the signature:
|
|
|
74
74
|
private_key = PrivateKey('EDB671EB741BD676969D8A035271D1EE5E75DF33278083D877F23615EB839FEC')
|
|
75
75
|
signature = facade.sign_transaction(facade.KeyPair(private_key), transaction)
|
|
76
76
|
|
|
77
|
-
json_payload = facade.
|
|
77
|
+
json_payload = facade.transaction_factory.attach_signature(transaction, signature)
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
Finally, send the payload to the desired network using the specified node endpoint:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = 'symbol-sdk-python'
|
|
3
|
-
version = '3.
|
|
3
|
+
version = '3.3.0'
|
|
4
4
|
description = 'Symbol SDK'
|
|
5
5
|
authors = ['Symbol Contributors <contributors@symbol.dev>']
|
|
6
6
|
maintainers = ['Symbol Contributors <contributors@symbol.dev>']
|
|
@@ -17,13 +17,13 @@ keywords = ['symbol', 'sdk', 'Symbol SDK']
|
|
|
17
17
|
classifiers = ['Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11']
|
|
18
18
|
|
|
19
19
|
[tool.poetry.dependencies]
|
|
20
|
-
python = "^3.9"
|
|
21
|
-
cryptography = ">=
|
|
20
|
+
python = "^3.9.2"
|
|
21
|
+
cryptography = ">=46.0.1,<46.1.0"
|
|
22
22
|
mnemonic = ">=0.20,<1.0"
|
|
23
|
-
pillow = ">=
|
|
24
|
-
pynacl = ">=1.
|
|
23
|
+
pillow = ">=11.3.0,<11.4.0"
|
|
24
|
+
pynacl = ">=1.6.0,<1.7.0"
|
|
25
25
|
pyyaml = ">=6.0.1,<6.1.0"
|
|
26
26
|
pyzbar = ">=0.1.9,<0.2.0"
|
|
27
|
-
qrcode = ">=
|
|
27
|
+
qrcode = ">=8.0,<9.0"
|
|
28
28
|
ripemd-hash = ">=1.0.1,<1.1.0"
|
|
29
29
|
safe-pysha3 = ">=1.0.4,<1.1.0"
|
|
@@ -49,3 +49,7 @@ class BaseValue(Ordered):
|
|
|
49
49
|
unsigned_value = self.value + upper_bound_plus_one
|
|
50
50
|
|
|
51
51
|
return f'0x{unsigned_value:0{self.size * 2}X}'
|
|
52
|
+
|
|
53
|
+
def to_json(self):
|
|
54
|
+
"""Returns representation of this object that can be stored in JSON."""
|
|
55
|
+
return str(self.value) if 8 <= self.size else self.value
|
|
@@ -9,7 +9,7 @@ class Network:
|
|
|
9
9
|
"""Represents a network."""
|
|
10
10
|
|
|
11
11
|
def __init__(self, name, identifier, datetime_converter, address_class, network_timestamp_class):
|
|
12
|
-
# pylint: disable=too-many-arguments
|
|
12
|
+
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
13
13
|
|
|
14
14
|
"""Creates a new network with the specified properties."""
|
|
15
15
|
self.name = name
|
|
@@ -93,16 +93,18 @@ class NemFacade:
|
|
|
93
93
|
return Hash256(sha3.keccak_256(non_verifiable_transaction.serialize()).digest())
|
|
94
94
|
|
|
95
95
|
@staticmethod
|
|
96
|
-
def
|
|
97
|
-
"""
|
|
96
|
+
def extract_signing_payload(transaction):
|
|
97
|
+
"""Gets the payload to sign given a NEM transaction."""
|
|
98
98
|
non_verifiable_transaction = TransactionFactory.to_non_verifiable_transaction(transaction)
|
|
99
|
-
return
|
|
99
|
+
return non_verifiable_transaction.serialize()
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
def sign_transaction(self, key_pair, transaction):
|
|
102
|
+
"""Signs a NEM transaction."""
|
|
103
|
+
return key_pair.sign(self.extract_signing_payload(transaction))
|
|
104
|
+
|
|
105
|
+
def verify_transaction(self, transaction, signature):
|
|
103
106
|
"""Verifies a NEM transaction."""
|
|
104
|
-
|
|
105
|
-
return Verifier(transaction.signer_public_key).verify(non_verifiable_transaction.serialize(), signature)
|
|
107
|
+
return Verifier(transaction.signer_public_key).verify(self.extract_signing_payload(transaction), signature)
|
|
106
108
|
|
|
107
109
|
def bip32_path(self, account_id):
|
|
108
110
|
"""Creates a network compatible BIP32 path for the specified account."""
|
|
@@ -19,13 +19,17 @@ TRANSACTION_HEADER_SIZE = sum(field[1] for field in [
|
|
|
19
19
|
('reserved2', 4)
|
|
20
20
|
])
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
PRE_V3_AGGREGATE_HASHED_SIZE = sum(field[1] for field in [
|
|
23
23
|
('version_network_type', 4),
|
|
24
24
|
('max_fee', 8),
|
|
25
25
|
('deadline', 8),
|
|
26
26
|
('transactions_hash', Hash256.SIZE)
|
|
27
27
|
])
|
|
28
28
|
|
|
29
|
+
AGGREGATE_HASHED_SIZE = PRE_V3_AGGREGATE_HASHED_SIZE + sum(field[1] for field in [
|
|
30
|
+
('payload_size', 4)
|
|
31
|
+
])
|
|
32
|
+
|
|
29
33
|
|
|
30
34
|
# region SymbolPublicAccount / SymbolAccount
|
|
31
35
|
|
|
@@ -59,6 +63,10 @@ class SymbolAccount(SymbolPublicAccount):
|
|
|
59
63
|
"""Cosigns a Symbol transaction."""
|
|
60
64
|
return self._facade.cosign_transaction(self.key_pair, transaction, detached)
|
|
61
65
|
|
|
66
|
+
def cosign_transaction_hash(self, transaction_hash, detached=False):
|
|
67
|
+
"""Cosigns a Symbol transaction hash."""
|
|
68
|
+
return self._facade.cosign_transaction_hash(self.key_pair, transaction_hash, detached)
|
|
69
|
+
|
|
62
70
|
# endregion
|
|
63
71
|
|
|
64
72
|
|
|
@@ -116,22 +124,23 @@ class SymbolFacade:
|
|
|
116
124
|
hasher.update(self._transaction_data_buffer(transaction.serialize()))
|
|
117
125
|
return Hash256(hasher.digest())
|
|
118
126
|
|
|
119
|
-
def
|
|
120
|
-
"""
|
|
127
|
+
def extract_signing_payload(self, transaction):
|
|
128
|
+
"""Gets the payload to sign given a Symbol transaction."""
|
|
121
129
|
sign_buffer = self.network.generation_hash_seed.bytes
|
|
122
130
|
sign_buffer += self._transaction_data_buffer(transaction.serialize())
|
|
123
|
-
return
|
|
131
|
+
return sign_buffer
|
|
132
|
+
|
|
133
|
+
def sign_transaction(self, key_pair, transaction):
|
|
134
|
+
"""Signs a Symbol transaction."""
|
|
135
|
+
return key_pair.sign(self.extract_signing_payload(transaction))
|
|
124
136
|
|
|
125
137
|
def verify_transaction(self, transaction, signature):
|
|
126
138
|
"""Verifies a Symbol transaction."""
|
|
127
|
-
|
|
128
|
-
verify_buffer += self._transaction_data_buffer(transaction.serialize())
|
|
129
|
-
return Verifier(transaction.signer_public_key).verify(verify_buffer, signature)
|
|
130
|
-
|
|
131
|
-
def cosign_transaction(self, key_pair, transaction, detached=False):
|
|
132
|
-
"""Cosigns a Symbol transaction."""
|
|
133
|
-
transaction_hash = self.hash_transaction(transaction)
|
|
139
|
+
return Verifier(transaction.signer_public_key).verify(self.extract_signing_payload(transaction), signature)
|
|
134
140
|
|
|
141
|
+
@staticmethod
|
|
142
|
+
def cosign_transaction_hash(key_pair, transaction_hash, detached=False):
|
|
143
|
+
"""Cosigns a Symbol transaction hash."""
|
|
135
144
|
cosignature = sc.DetachedCosignature() if detached else sc.Cosignature()
|
|
136
145
|
if detached:
|
|
137
146
|
cosignature.parent_hash = sc.Hash256(transaction_hash.bytes)
|
|
@@ -141,6 +150,11 @@ class SymbolFacade:
|
|
|
141
150
|
cosignature.signature = sc.Signature(key_pair.sign(transaction_hash.bytes).bytes)
|
|
142
151
|
return cosignature
|
|
143
152
|
|
|
153
|
+
def cosign_transaction(self, key_pair, transaction, detached=False):
|
|
154
|
+
"""Cosigns a Symbol transaction."""
|
|
155
|
+
transaction_hash = self.hash_transaction(transaction)
|
|
156
|
+
return self.cosign_transaction_hash(key_pair, transaction_hash, detached)
|
|
157
|
+
|
|
144
158
|
@staticmethod
|
|
145
159
|
def hash_embedded_transactions(embedded_transactions):
|
|
146
160
|
"""Hashes embedded transactions of an aggregate."""
|
|
@@ -171,6 +185,7 @@ class SymbolFacade:
|
|
|
171
185
|
data_buffer_start = TRANSACTION_HEADER_SIZE
|
|
172
186
|
data_buffer_end = len(transaction_buffer)
|
|
173
187
|
if SymbolFacade._is_aggregate_transaction(transaction_buffer):
|
|
174
|
-
|
|
188
|
+
version = transaction_buffer[TRANSACTION_HEADER_SIZE]
|
|
189
|
+
data_buffer_end = TRANSACTION_HEADER_SIZE + (AGGREGATE_HASHED_SIZE if version >= 3 else PRE_V3_AGGREGATE_HASHED_SIZE)
|
|
175
190
|
|
|
176
191
|
return transaction_buffer[data_buffer_start:data_buffer_end]
|