fixes #2943 bug where get forced user to purchase their own priced stream
This commit is contained in:
parent
575e471553
commit
8b55814ab2
2 changed files with 27 additions and 4 deletions
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue