diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 8919e2607..9ce55b321 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2154,7 +2154,7 @@ class Daemon(metaclass=JSONRPCServerType): List my stream and channel claims. Usage: - claim_list [--claim_type=] + claim_list [--claim_type=...] [--account_id=] [--wallet_id=] [--page=] [--page_size=] [--resolve] diff --git a/lbry/wallet/database.py b/lbry/wallet/database.py index 9941933fa..5cf5e9c8b 100644 --- a/lbry/wallet/database.py +++ b/lbry/wallet/database.py @@ -739,9 +739,11 @@ class Database(SQLiteMixin): @staticmethod def constrain_claims(constraints): - claim_type = constraints.pop('claim_type', None) - if claim_type is not None: - constraints['txo_type'] = TXO_TYPES[claim_type] + claim_types = constraints.pop('claim_type', None) + if isinstance(claim_types, str) and claim_types: + claim_types = [claim_types] + if isinstance(claim_types, list) and claim_types: + constraints['txo_type__in'] = [TXO_TYPES[ct] for ct in claim_types] else: constraints['txo_type__in'] = CLAIM_TYPES diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 24d605dee..7e69da840 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -384,6 +384,22 @@ class ClaimSearchCommand(ClaimTestCase): class ClaimCommands(ClaimTestCase): + async def test_claim_list_type_filtering(self): + await self.channel_create() + await self.stream_create() + + r = await self.claim_list(claim_type='channel') + self.assertEqual(1, len(r)) + self.assertEqual('channel', r[0]['value_type']) + + r = await self.claim_list(claim_type='stream') + self.assertEqual(1, len(r)) + self.assertEqual('stream', r[0]['value_type']) + + r = await self.claim_list(claim_type=['stream', 'channel']) + self.assertEqual(2, len(r)) + self.assertEqual({'stream', 'channel'}, {c['value_type'] for c in r}) + async def test_claim_stream_channel_list_with_resolve(self): await self.channel_create() await self.stream_create()