Browse Source

use None as timestamp for pending transactions

283
thomasv 12 years ago
parent
commit
8ec2b16e21
  1. 5
      lib/gui_qt.py
  2. 7
      lib/verifier.py
  3. 12
      lib/wallet.py

5
lib/gui_qt.py

@ -333,8 +333,9 @@ class ElectrumWindow(QMainWindow):
tx = self.wallet.transactions.get(tx_hash) tx = self.wallet.transactions.get(tx_hash)
conf = self.wallet.verifier.get_confirmations(tx_hash) conf = self.wallet.verifier.get_confirmations(tx_hash)
if conf: timestamp = tx.get('timestamp')
time_str = datetime.datetime.fromtimestamp( tx['timestamp']).isoformat(' ')[:-3] if conf and timestamp:
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
else: else:
time_str = 'pending' time_str = 'pending'

7
lib/verifier.py

@ -361,8 +361,7 @@ class WalletVerifier(threading.Thread):
def get_timestamp(self, tx_height): def get_timestamp(self, tx_height):
if tx_height>0: if tx_height>0:
header = self.read_header(tx_height) header = self.read_header(tx_height)
timestamp = header.get('timestamp') if header else 0 if header:
else: return header.get('timestamp')
timestamp = 1e12
return timestamp

12
lib/wallet.py

@ -585,8 +585,7 @@ class Wallet:
def get_tx_history(self): def get_tx_history(self):
with self.lock: with self.lock:
lines = self.transactions.values() lines = self.transactions.values()
lines.sort(key = lambda x: x.get('timestamp') if x.get('timestamp') else 1e12)
lines = sorted(lines, key=operator.itemgetter("timestamp"))
return lines return lines
def get_transactions_at_height(self, height): def get_transactions_at_height(self, height):
@ -901,7 +900,8 @@ class Wallet:
def set_verifier(self, verifier): def set_verifier(self, verifier):
self.verifier = verifier self.verifier = verifier
# review transactions (they might not all be in history) # review stored transactions and send them to the verifier
# (they are not necessarily in the history, because history items might have have been pruned)
for tx_hash, tx in self.transactions.items(): for tx_hash, tx in self.transactions.items():
tx_height = tx.get('height') tx_height = tx.get('height')
if tx_height <1: if tx_height <1:
@ -914,11 +914,9 @@ class Wallet:
# set the timestamp for transactions that need it # set the timestamp for transactions that need it
if tx and not tx.get('timestamp'): if tx and not tx.get('timestamp'):
timestamp = self.verifier.get_timestamp(tx_height) timestamp = self.verifier.get_timestamp(tx_height)
if timestamp: self.set_tx_timestamp(tx_hash, timestamp)
self.set_tx_timestamp(tx_hash, timestamp)
# review existing history # review transactions that are in the history
for addr, hist in self.history.items(): for addr, hist in self.history.items():
if hist == ['*']: continue if hist == ['*']: continue
for tx_hash, tx_height in hist: for tx_hash, tx_height in hist:

Loading…
Cancel
Save