mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
teos - Adds LocatorCache
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from common.logger import Logger
|
||||
from common.exceptions import BasicException
|
||||
|
||||
from teos import LOG_PREFIX
|
||||
from teos.tools import bitcoin_cli
|
||||
@@ -7,6 +8,10 @@ from teos.utils.auth_proxy import JSONRPCException
|
||||
logger = Logger(actor="BlockProcessor", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
class InvalidTransactionFormat(BasicException):
|
||||
"""Raised when a transaction is not properly formatted"""
|
||||
|
||||
|
||||
class BlockProcessor:
|
||||
"""
|
||||
The :class:`BlockProcessor` contains methods related to the blockchain. Most of its methods require communication
|
||||
@@ -89,17 +94,19 @@ class BlockProcessor:
|
||||
raw_tx (:obj:`str`): the hex representation of the transaction.
|
||||
|
||||
Returns:
|
||||
:obj:`dict` or :obj:`None`: The decoding of the given ``raw_tx`` if the transaction is well formatted.
|
||||
:obj:`dict`: The decoding of the given ``raw_tx`` if the transaction is well formatted.
|
||||
|
||||
Returns ``None`` otherwise.
|
||||
Raises:
|
||||
:obj:`InvalidTransactionFormat`: If the provided ``raw_tx`` has invalid format.
|
||||
"""
|
||||
|
||||
try:
|
||||
tx = bitcoin_cli(self.btc_connect_params).decoderawtransaction(raw_tx)
|
||||
|
||||
except JSONRPCException as e:
|
||||
tx = None
|
||||
logger.error("Cannot build transaction from decoded data", error=e.error)
|
||||
msg = "Cannot build transaction from decoded data"
|
||||
logger.error(msg, error=e.error)
|
||||
raise InvalidTransactionFormat(msg)
|
||||
|
||||
return tx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user