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