fix transaction order in history
This commit is contained in:
parent
a5168cc09f
commit
cac030e2ee
|
@ -35,7 +35,7 @@ class WalletVerifier(threading.Thread):
|
||||||
self.transactions = {} # requested verifications (with height sent by the requestor)
|
self.transactions = {} # requested verifications (with height sent by the requestor)
|
||||||
self.interface.register_channel('verifier')
|
self.interface.register_channel('verifier')
|
||||||
|
|
||||||
self.verified_tx = config.get('verified_tx2',{}) # height, timestamp of verified transactions
|
self.verified_tx = config.get('verified_tx3',{}) # height, timestamp of verified transactions
|
||||||
self.merkle_roots = config.get('merkle_roots',{}) # hashed by me
|
self.merkle_roots = config.get('merkle_roots',{}) # hashed by me
|
||||||
|
|
||||||
self.targets = config.get('targets',{}) # compute targets
|
self.targets = config.get('targets',{}) # compute targets
|
||||||
|
@ -50,7 +50,7 @@ class WalletVerifier(threading.Thread):
|
||||||
""" return the number of confirmations of a monitored transaction. """
|
""" return the number of confirmations of a monitored transaction. """
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if tx in self.verified_tx:
|
if tx in self.verified_tx:
|
||||||
height, timestamp = self.verified_tx[tx]
|
height, timestamp, pos = self.verified_tx[tx]
|
||||||
conf = (self.local_height - height + 1)
|
conf = (self.local_height - height + 1)
|
||||||
else:
|
else:
|
||||||
conf = 0
|
conf = 0
|
||||||
|
@ -183,7 +183,8 @@ class WalletVerifier(threading.Thread):
|
||||||
|
|
||||||
def verify_merkle(self, tx_hash, result):
|
def verify_merkle(self, tx_hash, result):
|
||||||
tx_height = result.get('block_height')
|
tx_height = result.get('block_height')
|
||||||
self.merkle_roots[tx_hash] = self.hash_merkle_root(result['merkle'], tx_hash, result.get('pos'))
|
pos = result.get('pos')
|
||||||
|
self.merkle_roots[tx_hash] = self.hash_merkle_root(result['merkle'], tx_hash, pos)
|
||||||
header = self.read_header(tx_height)
|
header = self.read_header(tx_height)
|
||||||
if not header: return
|
if not header: return
|
||||||
assert header.get('merkle_root') == self.merkle_roots[tx_hash]
|
assert header.get('merkle_root') == self.merkle_roots[tx_hash]
|
||||||
|
@ -191,9 +192,9 @@ class WalletVerifier(threading.Thread):
|
||||||
header = self.read_header(tx_height)
|
header = self.read_header(tx_height)
|
||||||
timestamp = header.get('timestamp')
|
timestamp = header.get('timestamp')
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.verified_tx[tx_hash] = (tx_height, timestamp)
|
self.verified_tx[tx_hash] = (tx_height, timestamp, pos)
|
||||||
print_error("verified %s"%tx_hash)
|
print_error("verified %s"%tx_hash)
|
||||||
self.config.set_key('verified_tx2', self.verified_tx, True)
|
self.config.set_key('verified_tx3', self.verified_tx, True)
|
||||||
self.interface.trigger_callback('updated')
|
self.interface.trigger_callback('updated')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -644,7 +644,7 @@ class Wallet:
|
||||||
def get_tx_history(self):
|
def get_tx_history(self):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
history = self.transactions.items()
|
history = self.transactions.items()
|
||||||
history.sort(key = lambda x: self.verifier.get_height(x[0]) if self.verifier.get_height(x[0]) else 1e12)
|
history.sort(key = lambda x: self.verifier.verified_tx.get(x[0]) if self.verifier.verified_tx.get(x[0]) else (1e12,0,0))
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
balance = 0
|
balance = 0
|
||||||
|
|
Loading…
Reference in New Issue