Do not return 'success' and 'reason' as outputs in claim commands
We throw an Exception instead
This commit is contained in:
parent
666a62ae3d
commit
bce41ddab4
2 changed files with 22 additions and 8 deletions
|
@ -463,11 +463,13 @@ class Wallet(object):
|
||||||
meta_for_return[k] = new_metadata[k]
|
meta_for_return[k] = new_metadata[k]
|
||||||
return defer.succeed(Metadata(meta_for_return))
|
return defer.succeed(Metadata(meta_for_return))
|
||||||
|
|
||||||
|
|
||||||
def claim_name(self, name, bid, m):
|
def claim_name(self, name, bid, m):
|
||||||
def _save_metadata(claim_out, metadata):
|
def _save_metadata(claim_out, metadata):
|
||||||
if not claim_out['success']:
|
if not claim_out['success']:
|
||||||
msg = 'Claim to name {} failed: {}'.format(name, claim_out['reason'])
|
msg = 'Claim to name {} failed: {}'.format(name, claim_out['reason'])
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
claim_out.pop('success')
|
||||||
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
|
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
|
||||||
log.debug("Saving metadata for claim %s %d" % (claim_outpoint['txid'], claim_outpoint['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'])
|
d = self._save_name_metadata(name, claim_outpoint, metadata['sources']['lbry_sd_hash'])
|
||||||
|
@ -494,11 +496,29 @@ class Wallet(object):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def abandon_claim(self, txid, nout):
|
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)
|
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):
|
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):
|
def get_tx(self, txid):
|
||||||
d = self._get_raw_tx(txid)
|
d = self._get_raw_tx(txid)
|
||||||
|
|
|
@ -1697,8 +1697,6 @@ class Daemon(AuthJSONRPCServer):
|
||||||
'metadata': metadata dictionary
|
'metadata': metadata dictionary
|
||||||
optional 'fee'
|
optional 'fee'
|
||||||
Returns:
|
Returns:
|
||||||
'success' : True if claim was succesful , False otherwise
|
|
||||||
'reason' : if not succesful, give reason
|
|
||||||
'txid' : txid of resulting transaction if succesful
|
'txid' : txid of resulting transaction if succesful
|
||||||
'nout' : nout of the resulting support claim if succesful
|
'nout' : nout of the resulting support claim if succesful
|
||||||
'fee' : fee paid for the claim transaction if succesful
|
'fee' : fee paid for the claim transaction if succesful
|
||||||
|
@ -1773,8 +1771,6 @@ class Daemon(AuthJSONRPCServer):
|
||||||
'txid': txid of claim, string
|
'txid': txid of claim, string
|
||||||
'nout': nout of claim, integer
|
'nout': nout of claim, integer
|
||||||
Return:
|
Return:
|
||||||
success : True if succesful , False otherwise
|
|
||||||
reason : if not succesful, give reason
|
|
||||||
txid : txid of resulting transaction if succesful
|
txid : txid of resulting transaction if succesful
|
||||||
fee : fee paid for the 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
|
'claim_id': claim id of claim to support
|
||||||
'amount': amount to support by
|
'amount': amount to support by
|
||||||
Return:
|
Return:
|
||||||
success : True if succesful , False otherwise
|
|
||||||
reason : if not succesful, give reason
|
|
||||||
txid : txid of resulting transaction if succesful
|
txid : txid of resulting transaction if succesful
|
||||||
nout : nout of the resulting support claim if succesful
|
nout : nout of the resulting support claim if succesful
|
||||||
fee : fee paid for the transaction if succesful
|
fee : fee paid for the transaction if succesful
|
||||||
|
|
Loading…
Reference in a new issue