Merge pull request #667 from lbryio/old_fee_check

Add check for old fee format and throw releveant exception
This commit is contained in:
Jack Robison 2017-06-02 16:06:51 -04:00 committed by GitHub
commit 8112658d70
2 changed files with 7 additions and 3 deletions

View file

@ -22,7 +22,7 @@ at anytime.
* *
### Deprecated ### Deprecated
* * Old fee metadata format in publish API command is deprecated, throw relevant exception
* *
### Removed ### Removed

View file

@ -1927,9 +1927,13 @@ class Daemon(AuthJSONRPCServer):
metadata['version'] = '_0_1_0' metadata['version'] = '_0_1_0'
# original format {'currency':{'address','amount'}} # check for original deprecated format {'currency':{'address','amount'}}
# add address to fee if unspecified {'version': ,'currency', 'address' , 'amount'} # add address, version to fee if unspecified
if 'fee' in metadata: if 'fee' in metadata:
if len(metadata['fee'].keys()) == 1 and isinstance(metadata['fee'].values()[0], dict):
raise Exception('Old format for fee no longer supported. ' \
'Fee must be specified as {"currency":,"address":,"amount":}')
if 'amount' in metadata['fee'] and 'currency' in metadata['fee']: if 'amount' in metadata['fee'] and 'currency' in metadata['fee']:
if not metadata['fee']['amount']: if not metadata['fee']['amount']:
log.warning("Stripping empty fee from published metadata") log.warning("Stripping empty fee from published metadata")