added --include_full_tx option to txo_list

This commit is contained in:
Lex Berezhny 2020-03-30 18:15:13 -04:00
parent 6de7a035fa
commit 886d1e8a19
2 changed files with 11 additions and 3 deletions

View file

@ -4251,7 +4251,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT)
async def jsonrpc_txo_spend(
self, account_id=None, wallet_id=None, batch_size=1000,
preview=False, blocking=False, **kwargs):
include_full_tx=False, preview=False, blocking=False, **kwargs):
"""
Spend transaction outputs, batching into multiple transactions as necessary.
@ -4280,6 +4280,7 @@ class Daemon(metaclass=JSONRPCServerType):
--preview : (bool) do not broadcast the transaction
--blocking : (bool) wait until abandon is in mempool
--batch_size=<batch_size> : (int) number of txos to spend per transactions
--include_full_tx : (bool) include entire tx in output and not just the txid
Returns: {List[Transaction]}
"""
@ -4300,7 +4301,9 @@ class Daemon(metaclass=JSONRPCServerType):
if not preview:
for tx in txs:
await self.broadcast_or_release(tx, blocking)
return txs
if include_full_tx:
return txs
return [{'txid': tx.id} for tx in txs]
@requires(WALLET_COMPONENT)
def jsonrpc_txo_sum(self, account_id=None, wallet_id=None, **kwargs):

View file

@ -616,7 +616,7 @@ class TransactionOutputCommands(ClaimTestCase):
await self.support_create(stream_id, '0.1')
await self.assertBalance(self.account, '7.978478')
self.assertEqual('1.0', lbc(await self.txo_sum(type='support', unspent=True)))
txs = await self.txo_spend(type='support', batch_size=3)
txs = await self.txo_spend(type='support', batch_size=3, include_full_tx=True)
self.assertEqual(4, len(txs))
self.assertEqual(3, len(txs[0]['inputs']))
self.assertEqual(3, len(txs[1]['inputs']))
@ -625,6 +625,11 @@ class TransactionOutputCommands(ClaimTestCase):
self.assertEqual('0.0', lbc(await self.txo_sum(type='support', unspent=True)))
await self.assertBalance(self.account, '8.977606')
await self.support_create(stream_id, '0.1')
txs = await self.daemon.jsonrpc_txo_spend(type='support', batch_size=3)
self.assertEqual(1, len(txs))
self.assertEqual({'txid'}, set(txs[0]))
class ClaimCommands(ClaimTestCase):