Merge pull request 'Adding blockstamp to history JSON' (#24) from g1walletbot into master

Reviewed-on: #24
This commit is contained in:
poka 2023-03-14 21:20:18 +01:00
commit bdc8b938fc
1 changed files with 14 additions and 7 deletions

View File

@ -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