@@ -157,14 +157,18 @@ def do_GET(self):
157
157
# need to investigate further, but this seems to work.
158
158
str_wallet_balance = str (proxy ._call ("getbalance" ))
159
159
160
- transactions = proxy ._call ("listtransactions" , "" , 50 )
160
+ transactions = proxy ._call ("listtransactions" , "" , 1000 )
161
161
# We want only the confirmed txs containing an OP_RETURN, from most to least recent
162
162
transactions = list (filter (lambda x : x ["confirmations" ] > 0 and x ["amount" ] == 0 , transactions ))
163
163
a_week_ago = (datetime .date .today () - datetime .timedelta (days = 7 )).timetuple ()
164
164
a_week_ago_posix = time .mktime (a_week_ago )
165
165
transactions_in_last_week = list (filter (lambda x : x ["time" ] > a_week_ago_posix , transactions ))
166
166
fees_in_last_week = reduce (lambda a ,b : a - b ["fee" ], transactions_in_last_week , 0 )
167
- time_between_transactions = round (168 / len (transactions_in_last_week )) # in hours based on 168 hours in a week
167
+ try :
168
+ time_between_transactions = str (round (168 / len (transactions_in_last_week ))) # in hours based on 168 hours in a week
169
+ time_between_transactions += " hour(s)"
170
+ except ZeroDivisionError :
171
+ time_between_transactions = "N/A"
168
172
transactions .sort (key = lambda x : x ["confirmations" ])
169
173
homepage_template = """<html>
170
174
<head>
@@ -186,7 +190,7 @@ def do_GET(self):
186
190
This address changes after every donation.
187
191
</p>
188
192
<p>
189
- Average time between transactions in the last week: {{ time_between_transactions }} hour(s) </br>
193
+ Average time between transactions in the last week: {{ time_between_transactions }} </br>
190
194
Fees used in the last week: {{ fees_in_last_week }} BTC</br>
191
195
Latest transactions: </br>
192
196
{{#transactions}}
0 commit comments