@@ -1,6 +1,7 @@
|
|||||||
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*.
|
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from decimal import Decimal
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
import matplotlib
|
import matplotlib
|
||||||
@@ -20,15 +21,15 @@ class NothingToPlotException(Exception):
|
|||||||
def plot_history(history):
|
def plot_history(history):
|
||||||
if len(history) == 0:
|
if len(history) == 0:
|
||||||
raise NothingToPlotException()
|
raise NothingToPlotException()
|
||||||
hist_in = defaultdict(int)
|
hist_in = defaultdict(Decimal)
|
||||||
hist_out = defaultdict(int)
|
hist_out = defaultdict(Decimal)
|
||||||
for item in history:
|
for item in history:
|
||||||
is_lightning = item.get("lightning", False)
|
is_lightning = item.get("lightning", False)
|
||||||
if not is_lightning and not item['confirmations']:
|
if not is_lightning and not item['confirmations']:
|
||||||
continue
|
continue
|
||||||
if item['timestamp'] is None:
|
if item['timestamp'] is None:
|
||||||
continue
|
continue
|
||||||
value = item['value'].value/COIN
|
value = Decimal(item['value'].value)/COIN
|
||||||
date = item['date']
|
date = item['date']
|
||||||
datenum = int(md.date2num(datetime.date(date.year, date.month, 1)))
|
datenum = int(md.date2num(datetime.date(date.year, date.month, 1)))
|
||||||
if value > 0:
|
if value > 0:
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ class Satoshis(object):
|
|||||||
def __new__(cls, value):
|
def __new__(cls, value):
|
||||||
self = super(Satoshis, cls).__new__(cls)
|
self = super(Satoshis, cls).__new__(cls)
|
||||||
# note: 'value' sometimes has msat precision
|
# note: 'value' sometimes has msat precision
|
||||||
|
assert isinstance(value, (int, Decimal)), f"unexpected type for {value=!r}"
|
||||||
self.value = value
|
self.value = value
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|||||||
@@ -1387,6 +1387,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
|||||||
'value': Satoshis(0),
|
'value': Satoshis(0),
|
||||||
'children': [],
|
'children': [],
|
||||||
'timestamp': 0,
|
'timestamp': 0,
|
||||||
|
'date': timestamp_to_datetime(0),
|
||||||
'fee_sat': 0,
|
'fee_sat': 0,
|
||||||
}
|
}
|
||||||
transactions[key] = parent
|
transactions[key] = parent
|
||||||
@@ -1401,6 +1402,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
|||||||
parent['lightning'] = False
|
parent['lightning'] = False
|
||||||
parent['txid'] = tx_item['txid']
|
parent['txid'] = tx_item['txid']
|
||||||
parent['timestamp'] = tx_item['timestamp']
|
parent['timestamp'] = tx_item['timestamp']
|
||||||
|
parent['date'] = timestamp_to_datetime(tx_item['timestamp'])
|
||||||
parent['height'] = tx_item['height']
|
parent['height'] = tx_item['height']
|
||||||
parent['confirmations'] = tx_item['confirmations']
|
parent['confirmations'] = tx_item['confirmations']
|
||||||
parent['children'].append(tx_item)
|
parent['children'].append(tx_item)
|
||||||
|
|||||||
Reference in New Issue
Block a user