Use account and reduce code + raise exception on claim not found
This commit is contained in:
parent
f5789775a2
commit
790991ecad
2 changed files with 13 additions and 10 deletions
|
@ -2326,18 +2326,20 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
|
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_claim_abandon(self, claim_id=None, txid=None, nout=None):
|
def jsonrpc_claim_abandon(self, claim_id=None, txid=None, nout=None, account_id=None):
|
||||||
"""
|
"""
|
||||||
Abandon a name and reclaim credits from the claim
|
Abandon a name and reclaim credits from the claim
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
claim_abandon [<claim_id> | --claim_id=<claim_id>]
|
claim_abandon [<claim_id> | --claim_id=<claim_id>]
|
||||||
[<txid> | --txid=<txid>] [<nout> | --nout=<nout>]
|
[<txid> | --txid=<txid>] [<nout> | --nout=<nout>]
|
||||||
|
[--account_id=<account_id>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--claim_id=<claim_id> : (str) claim_id of the claim to abandon
|
--claim_id=<claim_id> : (str) claim_id of the claim to abandon
|
||||||
--txid=<txid> : (str) txid of the claim to abandon
|
--txid=<txid> : (str) txid of the claim to abandon
|
||||||
--nout=<nout> : (int) nout of the claim to abandon
|
--nout=<nout> : (int) nout of the claim to abandon
|
||||||
|
--account_id=<account_id> : (str) id of the account to use
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(dict) Dictionary containing result of the claim
|
(dict) Dictionary containing result of the claim
|
||||||
|
@ -2346,6 +2348,10 @@ class Daemon(AuthJSONRPCServer):
|
||||||
txid : (str) txid of resulting transaction
|
txid : (str) txid of resulting transaction
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
account = self.default_account
|
||||||
|
if account_id is not None:
|
||||||
|
account = self.get_account_or_error("account_id", account_id, lbc_only=True)
|
||||||
|
|
||||||
if claim_id is None and txid is None and nout is None:
|
if claim_id is None and txid is None and nout is None:
|
||||||
raise Exception('Must specify claim_id, or txid and nout')
|
raise Exception('Must specify claim_id, or txid and nout')
|
||||||
if txid is None and nout is not None:
|
if txid is None and nout is not None:
|
||||||
|
@ -2353,7 +2359,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
if nout is None and txid is not None:
|
if nout is None and txid is not None:
|
||||||
raise Exception('Must specify nout')
|
raise Exception('Must specify nout')
|
||||||
|
|
||||||
tx = yield self.wallet_manager.abandon_claim(claim_id, txid, nout)
|
tx = yield self.wallet_manager.abandon_claim(claim_id, txid, nout, account)
|
||||||
self.analytics_manager.send_claim_action('abandon')
|
self.analytics_manager.send_claim_action('abandon')
|
||||||
defer.returnValue({
|
defer.returnValue({
|
||||||
"success": True,
|
"success": True,
|
||||||
|
|
|
@ -262,14 +262,11 @@ class LbryWalletManager(BaseWalletManager):
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def abandon_claim(self, claim_id, txid, nout):
|
def abandon_claim(self, claim_id, txid, nout, account):
|
||||||
account = self.default_account
|
claim = yield account.get_claim(claim_id=claim_id, txid=txid, nout=nout)
|
||||||
if claim_id is not None:
|
if not claim:
|
||||||
claim = yield account.get_claim(claim_id=claim_id)
|
raise Exception('No claim found for the specified claim_id or txid:nout')
|
||||||
elif txid is not None and nout is not None:
|
|
||||||
claim = yield account.get_claim(txid=txid, nout=nout)
|
|
||||||
else:
|
|
||||||
raise Exception('Must specify claim_id, or txid and nout')
|
|
||||||
tx = yield Transaction.abandon(claim, [account], account)
|
tx = yield Transaction.abandon(claim, [account], account)
|
||||||
yield account.ledger.broadcast(tx)
|
yield account.ledger.broadcast(tx)
|
||||||
# TODO: release reserved tx outputs in case anything fails by this point
|
# TODO: release reserved tx outputs in case anything fails by this point
|
||||||
|
|
Loading…
Reference in a new issue