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

Lifecycle : awaiting transaction now become validated when they can

parent e35c8ef6
No related branches found
No related tags found
No related merge requests found
...@@ -224,7 +224,7 @@ BOTTOM_SIGNATURE ...@@ -224,7 +224,7 @@ BOTTOM_SIGNATURE
for i in range(n, tx_max): for i in range(n, tx_max):
tx_lines += lines[n] tx_lines += lines[n]
n = n + 1 n = n + 1
transaction = Transaction.from_compact(version, tx_lines) transaction = Transaction.from_compact(currency, tx_lines)
transactions.append(transaction) transactions.append(transaction)
signature = Block.re_signature.match(lines[n]).group(1) signature = Block.re_signature.match(lines[n]).group(1)
......
...@@ -28,10 +28,14 @@ class Transfer(object): ...@@ -28,10 +28,14 @@ class Transfer(object):
self.metadata = metadata self.metadata = metadata
@classmethod @classmethod
def initiate(cls, txdoc, block, amount): def initiate(cls, txdoc, block, time, amount):
receivers = [o.pubkey for o in txdoc.outputs
if o.pubkey != txdoc.issuers[0]]
return cls(txdoc, Transfer.TO_SEND, {'block': block, return cls(txdoc, Transfer.TO_SEND, {'block': block,
'time': time,
'amount': amount, 'amount': amount,
'issuer': txdoc.issuers[0]}) 'issuer': txdoc.issuers[0],
'receiver': receivers[0]})
@classmethod @classmethod
def create_validated(cls, txdoc, metadata): def create_validated(cls, txdoc, metadata):
...@@ -57,7 +61,7 @@ class Transfer(object): ...@@ -57,7 +61,7 @@ class Transfer(object):
self.state = Transfer.REFUSED self.state = Transfer.REFUSED
raise raise
finally: finally:
self.metadata['block'] = community.current_blockid['number'] self.metadata['block'] = community.current_blockid()['number']
self.metadata['time'] = community.get_block().time self.metadata['time'] = community.get_block().time
def check_registered(self, tx, metadata): def check_registered(self, tx, metadata):
......
...@@ -103,8 +103,10 @@ class Cache(): ...@@ -103,8 +103,10 @@ class Cache():
awaiting = [t for t in self._transfers awaiting = [t for t in self._transfers
if t.state == Transfer.AWAITING] if t.state == Transfer.AWAITING]
awaiting_docs = [t.txdoc for t in awaiting] awaiting_docs = [t.txdoc.signed_raw() for t in awaiting]
if tx not in awaiting_docs: logging.debug(tx.signed_raw())
logging.debug(awaiting_docs)
if tx.signed_raw() not in awaiting_docs:
transfer = Transfer.create_validated(tx, metadata) transfer = Transfer.create_validated(tx, metadata)
self._transfers.append(transfer) self._transfers.append(transfer)
for transfer in awaiting: for transfer in awaiting:
...@@ -259,8 +261,9 @@ class Wallet(object): ...@@ -259,8 +261,9 @@ class Wallet(object):
block_number = community.current_blockid()['number'] block_number = community.current_blockid()['number']
transfer = Transfer.initiate(tx, block_number, amount) time = community.get_block().time
transfer.send() transfer = Transfer.initiate(tx, block_number, time, amount)
transfer.send(community)
self.caches[community.currency]._transfers.append(transfer) self.caches[community.currency]._transfers.append(transfer)
def sources(self, community): def sources(self, community):
......
...@@ -140,9 +140,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -140,9 +140,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
dialog.accepted.connect(self.refresh_wallets) dialog.accepted.connect(self.refresh_wallets)
dialog.exec_() dialog.exec_()
currency_tab = self.currencies_tabwidget.currentWidget() currency_tab = self.currencies_tabwidget.currentWidget()
currency_tab.table_history.model().dataChanged.emit( '''currency_tab.table_history.model().sourceModel().dataChanged.emit(
QModelIndex(), QModelIndex(),
QModelIndex(), ()) QModelIndex(), ())
'''
currency_tab.table_history.model().invalidate()
def open_certification_dialog(self): def open_certification_dialog(self):
dialog = CertificationDialog(self.app.current_account, dialog = CertificationDialog(self.app.current_account,
......
...@@ -105,7 +105,10 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): ...@@ -105,7 +105,10 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
def change_current_community(self, index): def change_current_community(self, index):
self.community = self.sender.communities[index] self.community = self.sender.communities[index]
self.dividend = self.community.dividend() self.dividend = self.community.dividend()
self.label_total.setText(self.wallet.get_text(self.community)) amount = self.wallet.value(self.community)
ref_amount = self.sender.units_to_ref(amount, self.community)
ref_name = self.sender.ref_name(self.community.currency)
self.label_total.setText("{0} {1}".format(ref_amount, ref_name))
self.spinbox_amount.setSuffix(" " + self.community.currency) self.spinbox_amount.setSuffix(" " + self.community.currency)
self.spinbox_amount.setValue(0) self.spinbox_amount.setValue(0)
amount = self.wallet.value(self.community) amount = self.wallet.value(self.community)
...@@ -115,7 +118,10 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): ...@@ -115,7 +118,10 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
def change_displayed_wallet(self, index): def change_displayed_wallet(self, index):
self.wallet = self.sender.wallets[index] self.wallet = self.sender.wallets[index]
self.label_total.setText(self.wallet.get_text(self.community)) amount = self.wallet.value(self.community)
ref_amount = self.sender.units_to_ref(amount, self.community)
ref_name = self.sender.ref_name(self.community.currency)
self.label_total.setText("{0} {1}".format(ref_amount, ref_name))
self.spinbox_amount.setValue(0) self.spinbox_amount.setValue(0)
amount = self.wallet.value(self.community) amount = self.wallet.value(self.community)
relative = amount / self.dividend relative = amount / self.dividend
......
...@@ -73,7 +73,10 @@ class HistoryTableModel(QAbstractTableModel): ...@@ -73,7 +73,10 @@ class HistoryTableModel(QAbstractTableModel):
self.account = account self.account = account
self.community = community self.community = community
self.columns = ('Date', 'UID/Public key', 'Payment', 'Deposit', 'Comment') self.columns = ('Date', 'UID/Public key', 'Payment', 'Deposit', 'Comment')
self.transfers = self.account.transfers(community)
@property
def transfers(self):
return self.account.transfers(self.community)
def rowCount(self, parent): def rowCount(self, parent):
return len(self.transfers) return len(self.transfers)
......
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