Merge pull request #2359 from lbryio/fix-error-on-null-fee
Fix dust transaction error on zero amount content fee
This commit is contained in:
commit
9e8a3ef7fc
2 changed files with 34 additions and 1 deletions
|
@ -360,6 +360,10 @@ class StreamManager:
|
|||
)
|
||||
except asyncio.TimeoutError:
|
||||
raise ResolveTimeout(uri)
|
||||
except Exception as err:
|
||||
if isinstance(err, asyncio.CancelledError):
|
||||
raise
|
||||
raise ResolveError(f"Unexpected error resolving stream: {str(err)}")
|
||||
await self.storage.save_claims_for_resolve([
|
||||
value for value in resolved_result.values() if 'error' not in value
|
||||
])
|
||||
|
@ -391,7 +395,7 @@ class StreamManager:
|
|||
fee_amount, fee_address = None, None
|
||||
|
||||
# check that the fee is payable
|
||||
if not to_replace and claim.stream.has_fee:
|
||||
if not to_replace and claim.stream.has_fee and claim.stream.fee.amount:
|
||||
fee_amount = round(exchange_rate_manager.convert_currency(
|
||||
claim.stream.fee.currency, "LBC", claim.stream.fee.amount
|
||||
), 5)
|
||||
|
|
|
@ -277,6 +277,24 @@ class FileCommands(CommandTestCase):
|
|||
self.assertEqual(response['content_fee']['outputs'][0]['amount'], '2.0')
|
||||
self.assertEqual(response['content_fee']['outputs'][0]['address'], target_address)
|
||||
|
||||
async def test_null_fee(self):
|
||||
target_address = await self.blockchain.get_raw_change_address()
|
||||
tx = await self.stream_create(
|
||||
'nullfee', '0.01', data=b'no pay me, no',
|
||||
fee_currency='LBC', fee_address=target_address, fee_amount='1.0'
|
||||
)
|
||||
await self.__raw_value_update_no_fee_amount(tx, target_address)
|
||||
await self.daemon.jsonrpc_file_delete(claim_name='nullfee')
|
||||
response = await self.daemon.jsonrpc_get('lbry://nullfee')
|
||||
self.assertEqual(len(self.daemon.jsonrpc_file_list()), 1)
|
||||
self.assertIsNone(response.content_fee)
|
||||
self.assertTrue(response.stream_claim_info.claim.stream.has_fee)
|
||||
self.assertDictEqual(
|
||||
response.stream_claim_info.claim.stream.to_dict()['fee'],
|
||||
{'currency': 'LBC', 'address': target_address}
|
||||
)
|
||||
await self.daemon.jsonrpc_file_delete(claim_name='nullfee')
|
||||
|
||||
async def __raw_value_update_no_fee_address(self, tx, claim_address, **kwargs):
|
||||
tx = await self.daemon.jsonrpc_stream_update(
|
||||
self.get_claim_id(tx), preview=True, claim_address=claim_address, **kwargs
|
||||
|
@ -286,3 +304,14 @@ class FileCommands(CommandTestCase):
|
|||
await tx.sign([self.account])
|
||||
await self.broadcast(tx)
|
||||
await self.confirm_tx(tx.id)
|
||||
|
||||
async def __raw_value_update_no_fee_amount(self, tx, claim_address):
|
||||
tx = await self.daemon.jsonrpc_stream_update(
|
||||
self.get_claim_id(tx), preview=True, fee_currency='LBC', fee_amount='1.0', fee_address=claim_address,
|
||||
claim_address=claim_address
|
||||
)
|
||||
tx.outputs[0].claim.stream.fee.message.ClearField('amount')
|
||||
tx.outputs[0].script.generate()
|
||||
await tx.sign([self.account])
|
||||
await self.broadcast(tx)
|
||||
await self.confirm_tx(tx.id)
|
||||
|
|
Loading…
Reference in a new issue