confirmations fix

This commit is contained in:
Lex Berezhny 2018-12-06 00:21:42 -05:00
parent c90cca4b20
commit 16ff4b4e2c
2 changed files with 12 additions and 11 deletions

View file

@ -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),

View file

@ -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')