From fc587819b03770755304ff8e9ff07483852cbd80 Mon Sep 17 00:00:00 2001 From: Kapis Date: Tue, 14 Mar 2023 20:35:17 +0100 Subject: [PATCH] Adding blockstamp to history JSON --- lib/gvaHistory.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/gvaHistory.py b/lib/gvaHistory.py index c1d2525..3245467 100755 --- a/lib/gvaHistory.py +++ b/lib/gvaHistory.py @@ -43,6 +43,7 @@ class History: node { currency issuers + blockstamp outputs comment writtenTime @@ -57,13 +58,15 @@ class History: comment outputs receivedTime + blockstamp } - receiving { + sending { currency issuers comment outputs receivedTime + blockstamp } } balance(script: $script) { @@ -119,6 +122,7 @@ class History: trans[i] = [] trans[i].append(direction) trans[i].append(transaction['writtenTime']) + if direction == 'SENT': trans[i].append(outPubkey) amount = int('-' + output.split(':')[0]) @@ -133,12 +137,11 @@ class History: trans[i].append(round(amount/self.UD, 2)) trans[i].append(transaction['comment']) trans[i].append(base) + trans[i].append(transaction['blockstamp']) i += 1 # Parse transactions in mempool - for direction in self.historyDoc['txsHistoryMp']: - resBc = [] - resBc = self.historyDoc['txsHistoryMp'][direction] + for direction, resBc in self.historyDoc['txsHistoryMp'].items(): for j, transaction in enumerate(resBc): # print(transaction) transaction = resBc[j] @@ -147,9 +150,11 @@ class History: # if direction == 'RECEIVING' or self.pubkey != outPubkey: trans.append(i) trans[i] = [] - trans[i].append(direction) - trans[i].append(int(time.time())) - if direction == 'SENDING': + trans[i].append(direction.upper()) + trans[i].append(transaction['receivedTime']) + + # trans[i].append(int(time.time())) + if direction.upper() == 'SENDING': trans[i].append(outPubkey) amount = int('-' + output.split(':')[0]) else: @@ -163,6 +168,7 @@ class History: trans[i].append(round(amount/self.UD, 2)) trans[i].append(transaction['comment']) trans[i].append(base) + trans[i].append(transaction['blockstamp']) i += 1 # Order transactions by date @@ -263,6 +269,7 @@ class History: dailyJSON[i]['amount'] = trans[3] dailyJSON[i]['amountUD'] = trans[4] dailyJSON[i]['comment'] = trans[5] + dailyJSON[i]['blockstamp'] = trans[7] dailyJSON = json.dumps(dailyJSON, indent=2) # If we want to write JSON to a file