forked from LBRYCommunity/lbry-sdk
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])
|
||||
@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
|
||||
|
||||
Usage:
|
||||
claim_abandon [<claim_id> | --claim_id=<claim_id>]
|
||||
[<txid> | --txid=<txid>] [<nout> | --nout=<nout>]
|
||||
[--account_id=<account_id>]
|
||||
|
||||
Options:
|
||||
--claim_id=<claim_id> : (str) claim_id of the claim to abandon
|
||||
--txid=<txid> : (str) txid 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:
|
||||
(dict) Dictionary containing result of the claim
|
||||
|
@ -2346,6 +2348,10 @@ class Daemon(AuthJSONRPCServer):
|
|||
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:
|
||||
raise Exception('Must specify claim_id, or txid and nout')
|
||||
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:
|
||||
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')
|
||||
defer.returnValue({
|
||||
"success": True,
|
||||
|
|
|
@ -262,14 +262,11 @@ class LbryWalletManager(BaseWalletManager):
|
|||
return tx
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def abandon_claim(self, claim_id, txid, nout):
|
||||
account = self.default_account
|
||||
if claim_id is not None:
|
||||
claim = yield account.get_claim(claim_id=claim_id)
|
||||
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')
|
||||
def abandon_claim(self, claim_id, txid, nout, account):
|
||||
claim = yield account.get_claim(claim_id=claim_id, txid=txid, nout=nout)
|
||||
if not claim:
|
||||
raise Exception('No claim found for the specified claim_id or txid:nout')
|
||||
|
||||
tx = yield Transaction.abandon(claim, [account], account)
|
||||
yield account.ledger.broadcast(tx)
|
||||
# TODO: release reserved tx outputs in case anything fails by this point
|
||||
|
|
Loading…
Reference in a new issue