txo_plot returns lbc instead of dewies

This commit is contained in:
Lex Berezhny 2020-03-26 01:13:09 -04:00
parent f086ebbb8e
commit 5e2ddbfd86
2 changed files with 24 additions and 21 deletions

View file

@ -4284,7 +4284,7 @@ class Daemon(metaclass=JSONRPCServerType):
) )
@requires(WALLET_COMPONENT) @requires(WALLET_COMPONENT)
def jsonrpc_txo_plot( async def jsonrpc_txo_plot(
self, account_id=None, wallet_id=None, self, account_id=None, wallet_id=None,
days_back=0, start_day=None, days_after=None, end_day=None, **kwargs): days_back=0, start_day=None, days_after=None, end_day=None, **kwargs):
""" """
@ -4333,11 +4333,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: List[Dict] Returns: List[Dict]
""" """
wallet = self.wallet_manager.get_wallet_or_default(wallet_id) wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
return self.ledger.get_txo_plot( plot = await self.ledger.get_txo_plot(
wallet=wallet, accounts=[wallet.get_account_or_error(account_id)] if account_id else wallet.accounts, wallet=wallet, accounts=[wallet.get_account_or_error(account_id)] if account_id else wallet.accounts,
read_only=True, days_back=days_back, start_day=start_day, days_after=days_after, end_day=end_day, read_only=True, days_back=days_back, start_day=start_day, days_after=days_after, end_day=end_day,
**self._constrain_txo_from_kwargs({}, **kwargs) **self._constrain_txo_from_kwargs({}, **kwargs)
) )
for row in plot:
row['total'] = dewies_to_lbc(row['total'])
return plot
UTXO_DOC = """ UTXO_DOC = """
Unspent transaction management. Unspent transaction management.

View file

@ -9,7 +9,7 @@ from lbry.error import InsufficientFundsError
from lbry.extras.daemon.daemon import DEFAULT_PAGE_SIZE from lbry.extras.daemon.daemon import DEFAULT_PAGE_SIZE
from lbry.testcase import CommandTestCase from lbry.testcase import CommandTestCase
from lbry.wallet.transaction import Transaction from lbry.wallet.transaction import Transaction
from lbry.wallet.util import satoshis_to_coins as lbc, coins_to_satoshis as dewies from lbry.wallet.util import satoshis_to_coins as lbc
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -568,46 +568,46 @@ class TransactionOutputCommands(ClaimTestCase):
plot = await self.txo_plot(type='support') plot = await self.txo_plot(type='support')
self.assertEqual([ self.assertEqual([
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)
plot = await self.txo_plot(type='support', days_back=1) plot = await self.txo_plot(type='support', days_back=1)
self.assertEqual([ self.assertEqual([
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)
plot = await self.txo_plot(type='support', days_back=2) plot = await self.txo_plot(type='support', days_back=2)
self.assertEqual([ self.assertEqual([
{'day': '2016-06-23', 'total': dewies('0.5')}, {'day': '2016-06-23', 'total': '0.5'},
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)
plot = await self.txo_plot(type='support', start_day='2016-06-23') plot = await self.txo_plot(type='support', start_day='2016-06-23')
self.assertEqual([ self.assertEqual([
{'day': '2016-06-23', 'total': dewies('0.5')}, {'day': '2016-06-23', 'total': '0.5'},
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)
plot = await self.txo_plot(type='support', start_day='2016-06-24') plot = await self.txo_plot(type='support', start_day='2016-06-24')
self.assertEqual([ self.assertEqual([
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)
plot = await self.txo_plot(type='support', start_day='2016-06-23', end_day='2016-06-24') plot = await self.txo_plot(type='support', start_day='2016-06-23', end_day='2016-06-24')
self.assertEqual([ self.assertEqual([
{'day': '2016-06-23', 'total': dewies('0.5')}, {'day': '2016-06-23', 'total': '0.5'},
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
], plot) ], plot)
plot = await self.txo_plot(type='support', start_day='2016-06-23', days_after=1) plot = await self.txo_plot(type='support', start_day='2016-06-23', days_after=1)
self.assertEqual([ self.assertEqual([
{'day': '2016-06-23', 'total': dewies('0.5')}, {'day': '2016-06-23', 'total': '0.5'},
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
], plot) ], plot)
plot = await self.txo_plot(type='support', start_day='2016-06-23', days_after=2) plot = await self.txo_plot(type='support', start_day='2016-06-23', days_after=2)
self.assertEqual([ self.assertEqual([
{'day': '2016-06-23', 'total': dewies('0.5')}, {'day': '2016-06-23', 'total': '0.5'},
{'day': '2016-06-24', 'total': dewies('0.9')}, {'day': '2016-06-24', 'total': '0.9'},
{'day': '2016-06-25', 'total': dewies('0.6')}, {'day': '2016-06-25', 'total': '0.6'},
], plot) ], plot)