fix bug: fee address defaults respect replace
This commit is contained in:
parent
c9b3c2e6aa
commit
54e53932bd
3 changed files with 18 additions and 9 deletions
|
@ -2610,7 +2610,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
channel = old_txo.channel
|
||||
|
||||
if 'fee_amount' in kwargs:
|
||||
kwargs['fee_address'] = self.get_fee_address(kwargs, claim_address)
|
||||
kwargs['fee_address'] = self.get_fee_address(kwargs, old_txo.claim.stream.fee.address or claim_address)
|
||||
|
||||
if replace:
|
||||
claim = Claim()
|
||||
|
|
|
@ -206,8 +206,8 @@ class Fee(Metadata):
|
|||
def update(self, address: str = None, currency: str = None, amount=None):
|
||||
if address is not None:
|
||||
self.address = address
|
||||
if currency is not None and amount is not None:
|
||||
currency = currency.lower()
|
||||
if (self.message.currency or currency is not None) and amount is not None:
|
||||
currency = currency.lower() if currency is not None else self.currency.lower()
|
||||
assert currency in ('lbc', 'btc', 'usd'), f'Unknown currency type: {currency}'
|
||||
setattr(self, currency, Decimal(amount))
|
||||
|
||||
|
|
|
@ -708,16 +708,25 @@ class StreamCommands(ClaimTestCase):
|
|||
# clearing fee
|
||||
tx = await self.out(self.stream_update(claim_id, clear_fee=True))
|
||||
txo = tx['outputs'][0]
|
||||
del fixed_values['fee']
|
||||
fixed_fee = fixed_values.pop('fee')
|
||||
self.assertEqual(txo['value'], fixed_values)
|
||||
|
||||
# setting the fee after it has been cleared, without a fee address, sets the fee address to claim address
|
||||
tx = await self.out(self.stream_update(claim_id, fee_amount='0.1', fee_currency='LBC'))
|
||||
tx = await self.out(self.stream_update(
|
||||
claim_id, fee_amount=fixed_fee['amount'], fee_currency=fixed_fee['currency'],
|
||||
))
|
||||
txo = tx['outputs'][0]
|
||||
self.assertIn('fee', txo['value'])
|
||||
self.assertIn('address', txo['value']['fee'])
|
||||
self.assertEqual(txo['value']['fee']['address'], txo['address'])
|
||||
fixed_values['fee'] = txo['value']['fee']
|
||||
fixed_fee['address'] = txo['address']
|
||||
fixed_values['fee'] = fixed_fee
|
||||
self.assertEqual(txo['value'], fixed_values)
|
||||
|
||||
# update just the fee amount, shouldnt update fee address to claim address
|
||||
address = await self.daemon.jsonrpc_address_unused()
|
||||
tx = await self.out(self.stream_update(
|
||||
claim_id, fee_amount='1.33', claim_address=address
|
||||
))
|
||||
fixed_values['fee']['amount'] = '1.33'
|
||||
self.assertEqual(tx['outputs'][0]['value'], fixed_values)
|
||||
|
||||
# modifying hash/size/name
|
||||
fixed_values['source']['name'] = 'changed_name'
|
||||
|
|
Loading…
Reference in a new issue