Do not return 'success' and 'reason' as outputs in claim commands

We throw an Exception instead
This commit is contained in:
Kay Kurokawa 2016-12-02 12:57:18 -05:00 committed by Job Evers-Meltzer
parent 666a62ae3d
commit bce41ddab4
2 changed files with 22 additions and 8 deletions

View file

@ -463,11 +463,13 @@ class Wallet(object):
meta_for_return[k] = new_metadata[k]
return defer.succeed(Metadata(meta_for_return))
def claim_name(self, name, bid, m):
def _save_metadata(claim_out, metadata):
if not claim_out['success']:
msg = 'Claim to name {} failed: {}'.format(name, claim_out['reason'])
raise Exception(msg)
claim_out.pop('success')
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
log.debug("Saving metadata for claim %s %d" % (claim_outpoint['txid'], claim_outpoint['nout']))
d = self._save_name_metadata(name, claim_outpoint, metadata['sources']['lbry_sd_hash'])
@ -494,11 +496,29 @@ class Wallet(object):
return d
def abandon_claim(self, txid, nout):
def _parse_abandon_claim_out(claim_out):
if not claim_out['success']:
msg = 'Abandon of {}:{} failed: {}'.format(txid, nout, claim_out['resason'])
raise Exception(msg)
claim_out.pop('success')
return defer.succeed(claim_out)
claim_outpoint = ClaimOutpoint(txid, nout)
return self._abandon_claim(claim_outpoint)
d = self._abandon_claim(claim_outpoint)
d.addCallback(lambda claim_out: _parse_abandon_claim_out(claim_out))
return d
def support_claim(self, name, claim_id, amount):
return self._support_claim(name, claim_id, amount)
def _parse_support_claim_out(claim_out):
if not claim_out['success']:
msg = 'Support of {}:{} failed: {}'.format(name, claim_id, claim_out['reason'])
raise Exception(msg)
claim_out.pop('success')
return defer.succeed(claim_out)
d = self._support_claim(name, claim_id, amount)
d.addCallback(lambda claim_out: _parse_support_claim_out(claim_out))
return d
def get_tx(self, txid):
d = self._get_raw_tx(txid)

View file

@ -1697,8 +1697,6 @@ class Daemon(AuthJSONRPCServer):
'metadata': metadata dictionary
optional 'fee'
Returns:
'success' : True if claim was succesful , False otherwise
'reason' : if not succesful, give reason
'txid' : txid of resulting transaction if succesful
'nout' : nout of the resulting support claim if succesful
'fee' : fee paid for the claim transaction if succesful
@ -1773,8 +1771,6 @@ class Daemon(AuthJSONRPCServer):
'txid': txid of claim, string
'nout': nout of claim, integer
Return:
success : True if succesful , False otherwise
reason : if not succesful, give reason
txid : txid of resulting transaction if succesful
fee : fee paid for the transaction if succesful
"""
@ -1818,8 +1814,6 @@ class Daemon(AuthJSONRPCServer):
'claim_id': claim id of claim to support
'amount': amount to support by
Return:
success : True if succesful , False otherwise
reason : if not succesful, give reason
txid : txid of resulting transaction if succesful
nout : nout of the resulting support claim if succesful
fee : fee paid for the transaction if succesful