Skip to content
Snippets Groups Projects
Commit a7fc1f55 authored by inso's avatar inso
Browse files

Fix some bugs in transactions parsing

parent 40c15fb4
No related branches found
No related tags found
No related merge requests found
......@@ -18,12 +18,27 @@ from PyQt5.QtCore import QObject, pyqtSignal
class LocalState(Enum):
"""
The local state describes how the identity exists locally :
COMPLETED means all its related datas (certifiers, certified...)
were succefully downloaded
PARTIAL means not all data are present locally
NOT_FOUND means it could not be found anywhere
"""
NOT_FOUND = 0
PARTIAL = 1
COMPLETED = 2
class BlockchainState(Enum):
"""
The blockchain state describes how the identity
was found :
VALIDATED means it was found in the blockchain
BUFFERED means it was found via a lookup but not in the
blockchain
NOT_FOUND means it could not be found anywhere
"""
NOT_FOUND = 0
BUFFERED = 1
VALIDATED = 2
......
......@@ -117,7 +117,7 @@ class Transfer(QObject):
blockid = yield from community.blockid()
block = yield from community.bma_access.future_request(qtbma.blockchain.Block,
req_args={'number': blockid['number']})
if block != qtbma.Blockchain.Block.null_value:
if block != qtbma.blockchain.Block.null_value:
self._metadata['block'] = blockid['number']
self._metadata['time'] = block['medianTime']
......
......@@ -77,7 +77,7 @@ class TxHistory():
if o.pubkey != txdata['issuers'][0]]
block_number = txdata['block_number']
if block_number + self.app.preferences['data_validation'] >= current_block:
if block_number + self.app.preferences['data_validation'] >= current_block["number"]:
state = Transfer.VALIDATED
else:
state = Transfer.VALIDATING
......@@ -118,7 +118,7 @@ class TxHistory():
# We check if the transaction correspond to one we sent
# but not from this cutecoin Instance
if txdata['hash'] not in [t.metadata['hash'] for t in awaiting]:
if txdata['hash'] not in [t.hash for t in awaiting]:
# If the wallet pubkey is in the issuers we sent this transaction
if in_issuers:
outputs = [o for o in tx_outputs
......@@ -141,14 +141,14 @@ class TxHistory():
amount += o.amount
metadata['amount'] = amount
if txdata['hash'] not in [t['hash'] for t in awaiting]:
if txdata['hash'] not in [t.hash for t in awaiting]:
transfer = Transfer.create_from_blockchain(txdata['hash'],
state,
metadata.copy())
received_list.append(transfer)
return transfer
else:
transfer = [t for t in awaiting if t.metadata['hash'] == txdata['hash']][0]
transfer = [t for t in awaiting if t.hash == txdata['hash']][0]
transfer.check_registered(txdata['hash'], current_block, mediantime,
self.app.preferences['data_validation'])
return None
......@@ -208,7 +208,8 @@ class TxHistory():
parsed_block,
current_block['number']))
else:
transfer = yield from self._parse_transaction(community, txdata, received_list, udid + txid)
transfer = yield from self._parse_transaction(community, txdata, received_list,
udid + txid, current_block)
if transfer:
new_transfers.append(transfer)
......
......@@ -79,11 +79,11 @@ class IdentitiesTableModel(QAbstractTableModel):
"""
super().__init__(parent)
self.community = community
self.columns_titles = {
'uid': self.tr('UID'),
self.columns_titles = {'uid': self.tr('UID'),
'pubkey': self.tr('Pubkey'),
'renewed': self.tr('Renewed'),
'expiration': self.tr('Expiration')}
'expiration': self.tr('Expiration'),
'validation': self.tr('Validation')}
self.columns_ids = ('uid', 'pubkey', 'renewed', 'expiration')
self.identities_data = []
self._identities = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment