correctly split value/fee in transaction_list

This commit is contained in:
Lex Berezhny 2018-11-28 14:41:45 -05:00
parent 443ce6352b
commit fe844581fd
2 changed files with 11 additions and 6 deletions

View file

@ -307,12 +307,14 @@ class LbryWalletManager(BaseWalletManager):
'support_info': [],
'abandon_info': []
}
if all([txi.txo_ref.txo is not None for txi in tx.inputs]):
item['value'] = dewies_to_lbc(tx.net_account_balance - tx.fee)
item['fee'] = dewies_to_lbc(tx.fee)
if all([txi.is_my_account for txi in tx.inputs]):
# fees only matter if we are the ones paying them
item['value'] = dewies_to_lbc(tx.net_account_balance+tx.fee)
item['fee'] = dewies_to_lbc(-tx.fee)
else:
# someone else paid the fees
item['value'] = dewies_to_lbc(tx.net_account_balance)
item['fee'] = '0' # can't calculate fee without all input txos
item['fee'] = '0.0'
for txo in tx.my_claim_outputs:
item['claim_info'].append({
'address': txo.get_address(account.ledger),

View file

@ -674,6 +674,7 @@ class ClaimManagement(CommandTestCase):
self.assertEqual(txs[0]['support_info'][0]['claim_id'], claim['claim_id'])
self.assertEqual(txs[0]['support_info'][0]['is_tip'], True)
self.assertEqual(txs[0]['value'], '1.0')
self.assertEqual(txs[0]['fee'], '0.0')
# verify that the outgoing tip is marked correctly as is_tip=True in account2
txs2 = await self.out(
@ -683,7 +684,8 @@ class ClaimManagement(CommandTestCase):
self.assertEqual(txs2[0]['support_info'][0]['balance_delta'], '-1.0')
self.assertEqual(txs2[0]['support_info'][0]['claim_id'], claim['claim_id'])
self.assertEqual(txs2[0]['support_info'][0]['is_tip'], True)
self.assertEqual(txs2[0]['value'], '-1.0001415')
self.assertEqual(txs2[0]['value'], '-1.0')
self.assertEqual(txs2[0]['fee'], '-0.0001415')
# send a support to the claim using account2
support = await self.out(
@ -703,4 +705,5 @@ class ClaimManagement(CommandTestCase):
self.assertEqual(txs2[0]['support_info'][0]['balance_delta'], '-2.0')
self.assertEqual(txs2[0]['support_info'][0]['claim_id'], claim['claim_id'])
self.assertEqual(txs2[0]['support_info'][0]['is_tip'], False)
self.assertEqual(txs2[0]['value'], '-0.0001415')
self.assertEqual(txs2[0]['value'], '0.0')
self.assertEqual(txs2[0]['fee'], '-0.0001415')