From 82dfd094acf3901fb4ab43a8696ec75c84c097cf Mon Sep 17 00:00:00 2001 From: MMGen Date: Wed, 29 May 2019 09:02:24 +0000 Subject: [PATCH] getbalance: fix incorrect display with 0-conf outputs --- mmgen/tw.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mmgen/tw.py b/mmgen/tw.py index 5492560d..fc0d7006 100755 --- a/mmgen/tw.py +++ b/mmgen/tw.py @@ -634,23 +634,30 @@ class TwGetBalance(MMGenObject): self.create_data() def create_data(self): - # 0: unconfirmed, 1: below minconf, 2: confirmed, 3: spendable + # 0: unconfirmed, 1: below minconf, 2: confirmed, 3: spendable (privkey in wallet) lbl_id = ('account','label')['label_api' in g.rpch.caps] for d in g.rpch.listunspent(0): - try: lbl = TwLabel(d[lbl_id],on_fail='silent') - except: lbl = None - if lbl: + try: + lbl = TwLabel(d[lbl_id],on_fail='silent') + except: + lbl,key = None,'Non-wallet' + else: if lbl.mmid.type == 'mmgen': key = lbl.mmid.obj.sid if key not in self.data: self.data[key] = [g.proto.coin_amt('0')] * 4 - else: key = 'Non-MMGen' - else: key = 'Non-wallet' + else: + key = 'Non-MMGen' - conf_level = 0 if not d['confirmations'] else 1 if d['confirmations'] < self.minconf else 2 + if not d['confirmations']: + self.data['TOTAL'][0] += d['amount'] + self.data[key][0] += d['amount'] + + conf_level = (1,2)[d['confirmations'] >= self.minconf] self.data['TOTAL'][conf_level] += d['amount'] self.data[key][conf_level] += d['amount'] + if d['spendable']: self.data[key][3] += d['amount']