diff --git a/lbry/file/file_manager.py b/lbry/file/file_manager.py index 906362858..094ab1edc 100644 --- a/lbry/file/file_manager.py +++ b/lbry/file/file_manager.py @@ -85,8 +85,11 @@ class FileManager: raise ResolveError("cannot download a channel claim, specify a /path") try: resolved_result = await asyncio.wait_for( - self.wallet_manager.ledger.resolve(wallet.accounts, [uri], include_purchase_receipt=True), - resolve_timeout + self.wallet_manager.ledger.resolve( + wallet.accounts, [uri], + include_purchase_receipt=True, + include_is_my_output=True + ), resolve_timeout ) except asyncio.TimeoutError: raise ResolveTimeoutError(uri) @@ -170,7 +173,14 @@ class FileManager: # pay fee #################### - if not to_replace and txo.has_price and not txo.purchase_receipt: + needs_purchasing = ( + not to_replace and + not txo.is_my_output and + txo.has_price and + not txo.purchase_receipt + ) + + if needs_purchasing: payment = await self.wallet_manager.create_purchase_transaction( wallet.accounts, txo, exchange_rate_manager ) diff --git a/tests/integration/blockchain/test_purchase_command.py b/tests/integration/blockchain/test_purchase_command.py index 26aae8626..b8561ea1e 100644 --- a/tests/integration/blockchain/test_purchase_command.py +++ b/tests/integration/blockchain/test_purchase_command.py @@ -11,7 +11,9 @@ class PurchaseCommandTests(CommandTestCase): await super().asyncSetUp() self.merchant_address = await self.blockchain.get_raw_change_address() - async def priced_stream(self, name='stream', price: Optional[str] = '2.0', currency='LBC') -> Transaction: + async def priced_stream( + self, name='stream', price: Optional[str] = '2.0', currency='LBC', mine=False + ) -> Transaction: kwargs = {} if price and currency: kwargs = { @@ -19,6 +21,8 @@ class PurchaseCommandTests(CommandTestCase): 'fee_currency': currency, 'fee_address': self.merchant_address } + if not mine: + kwargs['claim_address'] = self.merchant_address file_path = self.create_upload_file(data=b'high value content') tx = await self.daemon.jsonrpc_stream_create( name, '0.01', file_path=file_path, **kwargs @@ -182,3 +186,12 @@ class PurchaseCommandTests(CommandTestCase): await self.ledger.wait(spend) await self.assertBalance(self.account, '0.487695') self.assertItemCount(await self.daemon.jsonrpc_utxo_list(), 1) + + async def test_owner_not_required_purchase_own_content(self): + await self.priced_stream(mine=True) + # check that `get` doesn't purchase own claim + balance = await self.account.get_balance() + response = await self.daemon.jsonrpc_get('lbry://stream') + self.assertIsNone(response.content_fee) + self.assertEqual(await self.account.get_balance(), balance) + self.assertItemCount(await self.daemon.jsonrpc_purchase_list(), 0)