added --reposted_claim_id to txo_list

This commit is contained in:
Lex Berezhny 2020-03-20 20:22:57 -04:00
parent 6293e227ea
commit 5e0324cc91
3 changed files with 17 additions and 7 deletions

View file

@ -4112,7 +4112,7 @@ class Daemon(metaclass=JSONRPCServerType):
@staticmethod
def _constrain_txo_from_kwargs(
constraints, type=None, txid=None, # pylint: disable=redefined-builtin
claim_id=None, name=None, unspent=False,
claim_id=None, name=None, unspent=False, reposted_claim_id=None,
is_my_input_or_output=None, exclude_internal_transfers=False,
is_my_output=None, is_not_my_output=None,
is_my_input=None, is_not_my_input=None):
@ -4133,6 +4133,7 @@ class Daemon(metaclass=JSONRPCServerType):
database.constrain_single_or_list(constraints, 'claim_id', claim_id)
database.constrain_single_or_list(constraints, 'claim_name', name)
database.constrain_single_or_list(constraints, 'txid', txid)
database.constrain_single_or_list(constraints, 'reposted_claim_id', reposted_claim_id)
return constraints
@requires(WALLET_COMPONENT)
@ -4196,7 +4197,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT)
def jsonrpc_txo_sum(self, account_id=None, wallet_id=None, **kwargs):
"""
Sum transaction outputs.
Sum of transaction outputs.
Usage:
txo_list [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...]
@ -4204,8 +4205,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--is_my_input_or_output |
[[--is_my_output | --is_not_my_output] [--is_my_input | --is_not_my_input]]
]
[--exclude_internal_transfers]
[--wallet_id=<wallet_id>]
[--exclude_internal_transfers] [--wallet_id=<wallet_id>]
Options:
--type=<type> : (str or list) claim type: stream, channel, support,
@ -4228,7 +4228,7 @@ class Daemon(metaclass=JSONRPCServerType):
--account_id=<account_id> : (str) id of the account to query
--wallet_id=<wallet_id> : (str) restrict results to specific wallet
Returns: {Paginated[Output]}
Returns: int
"""
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
return self.ledger.get_txo_sum(

View file

@ -439,13 +439,16 @@ class Database(SQLiteMixin):
txo_type integer not null default 0,
claim_id text,
claim_name text
claim_name text,
reposted_claim_id text
);
create index if not exists txo_txid_idx on txo (txid);
create index if not exists txo_address_idx on txo (address);
create index if not exists txo_claim_id_idx on txo (claim_id);
create index if not exists txo_claim_name_idx on txo (claim_name);
create index if not exists txo_txo_type_idx on txo (txo_type);
create index if not exists txo_reposted_claim_idx on txo (reposted_claim_id);
"""
CREATE_TXI_TABLE = """
@ -483,7 +486,10 @@ class Database(SQLiteMixin):
}
if txo.is_claim:
if txo.can_decode_claim:
row['txo_type'] = TXO_TYPES.get(txo.claim.claim_type, TXO_TYPES['stream'])
claim = txo.claim
row['txo_type'] = TXO_TYPES.get(claim.claim_type, TXO_TYPES['stream'])
if claim.is_repost:
row['reposted_claim_id'] = claim.repost.reference.claim_id
else:
row['txo_type'] = TXO_TYPES['stream']
elif txo.is_support:

View file

@ -1023,12 +1023,16 @@ class StreamCommands(ClaimTestCase):
claim_id = self.get_claim_id(tx)
self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 0)
self.assertItemCount(await self.daemon.jsonrpc_txo_list(reposted_claim_id=claim_id), 0)
self.assertItemCount(await self.daemon.jsonrpc_txo_list(type='repost'), 0)
tx = await self.stream_repost(claim_id, 'newstuff-again', '1.1')
repost_id = self.get_claim_id(tx)
self.assertItemCount(await self.daemon.jsonrpc_claim_list(claim_type='repost'), 1)
self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 1)
self.assertEqual((await self.claim_search(reposted_claim_id=claim_id))[0]['claim_id'], repost_id)
self.assertEqual((await self.txo_list(reposted_claim_id=claim_id))[0]['claim_id'], repost_id)
self.assertEqual((await self.txo_list(type='repost'))[0]['claim_id'], repost_id)
# tags are inherited (non-common / indexed tags)
self.assertItemCount(await self.daemon.jsonrpc_claim_search(any_tags=['foo'], claim_type=['stream', 'repost']), 2)