From 8859c1b0c1fdc32d52e679f59d8e91faa1440173 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 13 Feb 2017 14:17:53 -0500 Subject: [PATCH] fix claim_abandon --- lbrynet/core/Wallet.py | 10 ++++++---- lbrynet/lbrynet_daemon/Daemon.py | 16 ++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index 61d16ee96..0aefe563e 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -657,18 +657,20 @@ class Wallet(object): yield self._save_name_metadata(name, claim_outpoint, _metadata['sources']['lbry_sd_hash']) defer.returnValue(claim) + @defer.inlineCallbacks 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']) + msg = 'Abandon of {}:{} failed: {}'.format(txid, nout, claim_out['reason']) raise Exception(msg) 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) claim_outpoint = ClaimOutpoint(txid, nout) - d = self._abandon_claim(claim_outpoint) - d.addCallback(lambda claim_out: _parse_abandon_claim_out(claim_out)) - return d + claim_out = yield self._abandon_claim(claim_outpoint) + result = yield _parse_abandon_claim_out(claim_out) + defer.returnValue(result) def support_claim(self, name, claim_id, amount): def _parse_support_claim_out(claim_out): diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 97b0c85cd..78f20773b 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1672,6 +1672,7 @@ class Daemon(AuthJSONRPCServer): return self.jsonrpc_claim_abandon(**kwargs) @AuthJSONRPCServer.auth_required + @defer.inlineCallbacks def jsonrpc_claim_abandon(self, txid, nout): """ Abandon a name and reclaim credits from the claim @@ -1683,15 +1684,14 @@ class Daemon(AuthJSONRPCServer): txid : txid of resulting 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() - d.addCallback(lambda _: self.session.wallet.abandon_claim(txid, nout)) - d.addCallback(_disp) - d.callback(None) # TODO: is this line necessary??? - return d + try: + abandon_claim_tx = yield self.session.wallet.abandon_claim(txid, nout) + response = yield self._render_response(abandon_claim_tx) + except Exception as err: + log.warning(err) + response = yield self._render_response(err) + defer.returnValue(response) @AuthJSONRPCServer.auth_required def jsonrpc_abandon_name(self, **kwargs):