lbry-sdk/lbrynet/metadata/Fee.py

40 lines
845 B
Python
Raw Normal View History

import logging
import fee_schemas
from lbrynet.metadata.StructuredDict import StructuredDict
log = logging.getLogger(__name__)
class FeeValidator(StructuredDict):
def __init__(self, fee):
self._versions = [
('0.0.1', fee_schemas.VER_001, None)
]
StructuredDict.__init__(self, fee, fee.get('ver', '0.0.1'))
2017-04-05 01:42:35 +02:00
self.currency_symbol = self['currency']
self.amount = self._get_amount()
2017-04-05 01:42:35 +02:00
self.address = self['address']
def _get_amount(self):
2017-04-05 01:42:35 +02:00
amt = self['amount']
try:
return float(amt)
except TypeError:
log.error('Failed to convert fee amount %s to float', amt)
raise
class LBCFeeValidator(StructuredDict):
pass
class BTCFeeValidator(StructuredDict):
pass
class USDFeeValidator(StructuredDict):
pass