From 16ff4b4e2c84d606bc258e20018d4bc1f10e95d5 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Thu, 6 Dec 2018 00:21:42 -0500 Subject: [PATCH] confirmations fix --- lbrynet/extras/wallet/manager.py | 21 ++++++++++----------- tests/integration/wallet/test_commands.py | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lbrynet/extras/wallet/manager.py b/lbrynet/extras/wallet/manager.py index 632c7dd3b..404c3c067 100644 --- a/lbrynet/extras/wallet/manager.py +++ b/lbrynet/extras/wallet/manager.py @@ -319,7 +319,7 @@ class LbryWalletManager(BaseWalletManager): 'txid': tx.id, 'timestamp': ts, 'date': datetime.fromtimestamp(ts).isoformat(' ')[:-3] if tx.height > 0 else None, - 'confirmations': headers.height - tx.height if tx.height > 0 else 0, + 'confirmations': (headers.height+1) - tx.height if tx.height > 0 else 0, 'claim_info': [], 'update_info': [], 'support_info': [], @@ -353,16 +353,15 @@ class LbryWalletManager(BaseWalletManager): and other_txo.claim_id == txo.claim_id: previous = other_txo break - assert previous is not None,\ - "Invalid claim update state, expected to find previous claim in input." - item['update_info'].append({ - 'address': txo.get_address(account.ledger), - 'balance_delta': dewies_to_lbc(previous.amount-txo.amount), - 'amount': dewies_to_lbc(txo.amount), - 'claim_id': txo.claim_id, - 'claim_name': txo.claim_name, - 'nout': txo.position - }) + if previous is not None: + item['update_info'].append({ + 'address': txo.get_address(account.ledger), + 'balance_delta': dewies_to_lbc(previous.amount-txo.amount), + 'amount': dewies_to_lbc(txo.amount), + 'claim_id': txo.claim_id, + 'claim_name': txo.claim_name, + 'nout': txo.position + }) else: # someone sent us their claim item['update_info'].append({ 'address': txo.get_address(account.ledger), diff --git a/tests/integration/wallet/test_commands.py b/tests/integration/wallet/test_commands.py index 47de5f91d..9bb2b255a 100644 --- a/tests/integration/wallet/test_commands.py +++ b/tests/integration/wallet/test_commands.py @@ -494,6 +494,7 @@ class ClaimManagement(CommandTestCase): self.assertTrue(claim['success']) await self.on_transaction_dict(claim['tx']) await self.generate(1) + await self.on_transaction_dict(claim['tx']) return claim async def test_create_update_and_abandon_claim(self): @@ -502,6 +503,7 @@ class ClaimManagement(CommandTestCase): claim = await self.make_claim(amount='2.5') # creates new claim txs = await self.out(self.daemon.jsonrpc_transaction_list()) self.assertEqual(len(txs[0]['claim_info']), 1) + self.assertEqual(txs[0]['confirmations'], '1') self.assertEqual(txs[0]['claim_info'][0]['balance_delta'], '-2.5') self.assertEqual(txs[0]['claim_info'][0]['claim_id'], claim['claim_id']) self.assertEqual(txs[0]['value'], '0.0')