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

Warning when account is near expiration

parent 39f3c1d4
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ class Transfer(object):
raise
finally:
self.metadata['block'] = community.current_blockid()['number']
self.metadata['time'] = community.get_block().time
self.metadata['time'] = community.get_block().mediantime
def check_registered(self, tx, metadata):
......
......@@ -89,7 +89,7 @@ class Cache():
logging.debug("Error in {0}".format(block_number))
raise
metadata = {'block': block_number,
'time': block_doc.time}
'time': block_doc.mediantime}
for tx in block_doc.transactions:
metadata['issuer'] = tx.issuers[0]
receivers = [o.pubkey for o in tx.outputs
......@@ -243,7 +243,7 @@ class Wallet(object):
def send_money(self, salt, password, community,
recipient, amount, message):
time = community.get_block().time
time = community.get_block().mediantime
block_number = community.current_blockid()['number']
key = None
logging.debug("Key : {0} : {1}".format(salt, password))
......
......@@ -99,7 +99,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self.tabs_account.setEnabled(True)
self.refresh_wallets()
blockchain_init = QDateTime()
blockchain_init.setTime_t(self.community.get_block(1).time)
blockchain_init.setTime_t(self.community.get_block(1).mediantime)
self.date_from.setMinimumDateTime(blockchain_init)
self.date_from.setDateTime(blockchain_init)
......@@ -170,8 +170,21 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
QModelIndex(),
[])
self.status_label.setText("Connected : Block {0}"
.format(block_number))
person = Person.lookup(self.account.pubkey, self.community)
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
current_time = QDateTime().currentDateTime()
sig_validity = self.community.get_parameters()['sigValidity']
warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (current_time > expiration_date*1000 - warning_expiration_time*1000)
text = "Connected : Block {0}".format(block_number)
if will_expire_soon:
days = QDateTime().currentDateTime().daysTo(QDateTime(expiration_date*1000))
text += " - Warning : Membership expiration in {0}".format(days)
self.status_label.setText(text)
def refresh_wallets(self):
if self.app.current_account:
......
......@@ -213,7 +213,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
'status': node_status
}
cert_time = self.get_block_median_time(certifier['meta']['block_number'])
cert_time = self.get_block_mediantime(certifier['meta']['block_number'])
# add only valid certification...
if (time.time() - cert_time) > self.signature_validity:
......@@ -367,7 +367,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
dialog.edit_pubkey.setText(metadata['id'])
dialog.exec_()
def get_block_median_time(self, number):
def get_block_mediantime(self, number):
try:
block = self.community.get_block(number)
except Exception as e:
......
......@@ -87,7 +87,7 @@ class MembersTableModel(QAbstractTableModel):
def member_data(self, pubkey):
person = Person.lookup(pubkey, self.community)
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).time
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
return (person.name, pubkey, join_date, expiration_date)
......
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