-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/deltaupdater-account' into develop
- Loading branch information
Showing
51 changed files
with
3,811 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
Transaction Class. Functionality depending on the address type. | ||
""" | ||
|
||
from typing import Union | ||
|
||
from ..utils import hex_to_bytes | ||
|
||
|
||
class TransactionHashUtxo: | ||
def __init__(self, txhash: Union[str, bytearray], config): | ||
raise NotImplementedError("TransactionUtxo not implemented yet") | ||
|
||
|
||
class TransactionHashAccount: | ||
def __init__(self, txhash: Union[str, bytearray], config): | ||
"""Init a transaction instance. | ||
Args: | ||
txhash (Union[str, bytearray]): transaction hash | ||
config (ConfigRow): entry from the config table in the transformed keyspace | ||
Raises: | ||
Exception: Description | ||
ValueError: Description | ||
""" | ||
self.prefix_length = int(config.tx_prefix_length) | ||
if type(txhash) == str: | ||
self.tx_hash_bytes = hex_to_bytes(txhash) | ||
elif type(txhash) == bytearray: | ||
self.tx_hash_bytes = txhash | ||
elif type(txhash) == bytes: | ||
self.tx_hash_bytes = bytearray(txhash) | ||
else: | ||
raise Exception(f"Unknown type for txhash type: {type(txhash)}") | ||
|
||
# todo potentially different length for tron, also saved in bytearray though | ||
if len(self.tx_hash_bytes) != 32: | ||
raise ValueError( | ||
f"Address is not the right length {len(self.tx_hash_bytes)}" | ||
) | ||
|
||
@property | ||
def hex(self) -> str: # noqa | ||
return self.tx_hash_bytes.hex() | ||
|
||
@property | ||
def db_encoding(self) -> str: | ||
return self.bytearray | ||
# return f"0x{self.hex}" | ||
|
||
@property | ||
def db_encoding_query(self) -> str: | ||
return f"0x{self.hex}" | ||
|
||
@property | ||
def prefix(self) -> str: | ||
return self.hex.upper()[: self.prefix_length] | ||
|
||
@property | ||
def bytearray(self) -> bytearray: # noqa | ||
return self.tx_hash_bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.