forked from LBRYCommunity/lbry-sdk
get without fee address defaults pays to claim address
This commit is contained in:
parent
1cc6b2e31e
commit
2b7cbf9759
3 changed files with 22 additions and 3 deletions
|
@ -217,11 +217,11 @@ class Fee(Metadata):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def address(self) -> str:
|
def address(self) -> str:
|
||||||
return Base58.encode(self.message.address)
|
return Base58.encode(self.address_bytes) if self.address_bytes else ''
|
||||||
|
|
||||||
@address.setter
|
@address.setter
|
||||||
def address(self, address: str):
|
def address(self, address: str):
|
||||||
self.message.address = Base58.decode(address)
|
self.address_bytes = Base58.decode(address)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def address_bytes(self) -> bytes:
|
def address_bytes(self) -> bytes:
|
||||||
|
|
|
@ -407,7 +407,7 @@ class StreamManager:
|
||||||
msg = f"fee of {fee_amount} exceeds max available balance"
|
msg = f"fee of {fee_amount} exceeds max available balance"
|
||||||
log.warning(msg)
|
log.warning(msg)
|
||||||
raise InsufficientFundsError(msg)
|
raise InsufficientFundsError(msg)
|
||||||
fee_address = claim.stream.fee.address
|
fee_address = claim.stream.fee.address or resolved['address']
|
||||||
|
|
||||||
stream = ManagedStream(
|
stream = ManagedStream(
|
||||||
self.loop, self.config, self.blob_manager, claim.stream.source.sd_hash, download_directory,
|
self.loop, self.config, self.blob_manager, claim.stream.source.sd_hash, download_directory,
|
||||||
|
|
|
@ -259,3 +259,22 @@ class FileCommands(CommandTestCase):
|
||||||
await self.daemon.stream_manager.start()
|
await self.daemon.stream_manager.start()
|
||||||
self.assertEqual(len(self.daemon.jsonrpc_file_list()), 1)
|
self.assertEqual(len(self.daemon.jsonrpc_file_list()), 1)
|
||||||
self.assertEqual(self.daemon.jsonrpc_file_list()[0].content_fee.raw, raw_content_fee)
|
self.assertEqual(self.daemon.jsonrpc_file_list()[0].content_fee.raw, raw_content_fee)
|
||||||
|
await self.daemon.jsonrpc_file_delete(claim_name='icanpay')
|
||||||
|
|
||||||
|
# PASS: no fee address --> use the claim address to pay
|
||||||
|
await self.stream_create(
|
||||||
|
'nofeeaddress', '0.01', data=b'free stuff?',
|
||||||
|
)
|
||||||
|
await self.stream_update(
|
||||||
|
claim_id=self.daemon.jsonrpc_file_list()[0].claim_id,
|
||||||
|
data=b'new price', fee_amount='2.0', fee_currency='LBC', claim_address=target_address
|
||||||
|
)
|
||||||
|
self.assertIs(self.daemon.jsonrpc_file_list()[0].stream_claim_info.claim.stream.fee.address, '')
|
||||||
|
await self.daemon.jsonrpc_file_delete(claim_name='nofeeaddress')
|
||||||
|
self.assertEqual(len(self.daemon.jsonrpc_file_list()), 0)
|
||||||
|
|
||||||
|
response = await self.out(self.daemon.jsonrpc_get('lbry://nofeeaddress'))
|
||||||
|
self.assertIsNotNone(response['content_fee'])
|
||||||
|
self.assertEqual(len(self.daemon.jsonrpc_file_list()), 1)
|
||||||
|
self.assertEqual(response['content_fee']['outputs'][0]['amount'], '2.0')
|
||||||
|
self.assertEqual(response['content_fee']['outputs'][0]['address'], target_address)
|
||||||
|
|
Loading…
Reference in a new issue