fix claim_abandon

This commit is contained in:
Jack Robison 2017-02-13 14:17:53 -05:00
parent 867275461c
commit 8859c1b0c1
2 changed files with 14 additions and 12 deletions

View file

@ -657,18 +657,20 @@ class Wallet(object):
yield self._save_name_metadata(name, claim_outpoint, _metadata['sources']['lbry_sd_hash']) yield self._save_name_metadata(name, claim_outpoint, _metadata['sources']['lbry_sd_hash'])
defer.returnValue(claim) defer.returnValue(claim)
@defer.inlineCallbacks
def abandon_claim(self, txid, nout): def abandon_claim(self, txid, nout):
def _parse_abandon_claim_out(claim_out): def _parse_abandon_claim_out(claim_out):
if not claim_out['success']: if not claim_out['success']:
msg = 'Abandon of {}:{} failed: {}'.format(txid, nout, claim_out['resason']) msg = 'Abandon of {}:{} failed: {}'.format(txid, nout, claim_out['reason'])
raise Exception(msg) raise Exception(msg)
claim_out = self._process_claim_out(claim_out) claim_out = self._process_claim_out(claim_out)
log.info("Abandoned claim tx %s (n: %i) --> %s", txid, nout, claim_out)
return defer.succeed(claim_out) return defer.succeed(claim_out)
claim_outpoint = ClaimOutpoint(txid, nout) claim_outpoint = ClaimOutpoint(txid, nout)
d = self._abandon_claim(claim_outpoint) claim_out = yield self._abandon_claim(claim_outpoint)
d.addCallback(lambda claim_out: _parse_abandon_claim_out(claim_out)) result = yield _parse_abandon_claim_out(claim_out)
return d defer.returnValue(result)
def support_claim(self, name, claim_id, amount): def support_claim(self, name, claim_id, amount):
def _parse_support_claim_out(claim_out): def _parse_support_claim_out(claim_out):

View file

@ -1672,6 +1672,7 @@ class Daemon(AuthJSONRPCServer):
return self.jsonrpc_claim_abandon(**kwargs) return self.jsonrpc_claim_abandon(**kwargs)
@AuthJSONRPCServer.auth_required @AuthJSONRPCServer.auth_required
@defer.inlineCallbacks
def jsonrpc_claim_abandon(self, txid, nout): def jsonrpc_claim_abandon(self, txid, nout):
""" """
Abandon a name and reclaim credits from the claim Abandon a name and reclaim credits from the claim
@ -1683,15 +1684,14 @@ class Daemon(AuthJSONRPCServer):
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
""" """
def _disp(x):
log.info("Abandoned name claim tx " + str(x))
return self._render_response(x)
d = defer.Deferred() try:
d.addCallback(lambda _: self.session.wallet.abandon_claim(txid, nout)) abandon_claim_tx = yield self.session.wallet.abandon_claim(txid, nout)
d.addCallback(_disp) response = yield self._render_response(abandon_claim_tx)
d.callback(None) # TODO: is this line necessary??? except Exception as err:
return d log.warning(err)
response = yield self._render_response(err)
defer.returnValue(response)
@AuthJSONRPCServer.auth_required @AuthJSONRPCServer.auth_required
def jsonrpc_abandon_name(self, **kwargs): def jsonrpc_abandon_name(self, **kwargs):