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