From d6e3b11026d24513d6022ecd8a6faf2120831f57 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 28 Nov 2017 11:00:17 -0500 Subject: [PATCH] add claim_renew --- CHANGELOG.md | 1 + lbrynet/core/Wallet.py | 12 ++++++++++++ lbrynet/daemon/Daemon.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3f7022a7..9846019ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ at anytime. ### Added * Added `channel_import` and `channel_export` commands * Added `is_mine` field to `channel_list` results + * Added `claim_renew` command ### Removed * Removed claim related filter arguments `name`, `claim_id`, and `outpoint` from `file_list`, `file_delete`, `file_set_status`, and `file_reflect` diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index 5f2f20ac1..10908d0f8 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -1132,6 +1132,12 @@ class Wallet(object): def _get_values_for_uris(self, page, page_size, *uris): return defer.fail(NotImplementedError()) + def _claim_renew_all_before_expiration(self, height): + return defer.fail(NotImplementedError()) + + def _claim_renew(self, txid, nout): + return defer.fail(NotImplementedError()) + def send_claim_to_address(self, claim_id, destination, amount): return defer.fail(NotImplementedError()) @@ -1512,6 +1518,12 @@ class LBRYumWallet(Wallet): def get_certificates_for_signing(self): return self._run_cmd_as_defer_succeed('getcertificatesforsigning') + def _claim_renew_all_before_expiration(self, height): + return self._run_cmd_as_defer_succeed('renewclaimsbeforeexpiration', height) + + def _claim_renew(self, txid, nout): + return self._run_cmd_as_defer_succeed('listunspent') + # TODO: get rid of this function. lbryum should take care of it def _save_wallet(self, val=None): self.wallet.storage.write() diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index f01bb524c..55630c6ad 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -1993,6 +1993,40 @@ class Daemon(AuthJSONRPCServer): self.analytics_manager.send_claim_action('new_support') defer.returnValue(result) + @AuthJSONRPCServer.auth_required + @defer.inlineCallbacks + def jsonrpc_claim_renew(self, outpoint=None, height=None): + """ + Renew claim(s) or support(s) + + Usage: + claim_renew ( | --outpoint=) | ( | --height=) + + Return: + (dict) Dictionary containing result of the claim/support renewals + { + 'tx' : (str) hex encoded transaction + 'txid' : (str) txid of resulting claim + 'nout' : (int) nout of the resulting claim + 'fee' : (float) fee paid for the claim transaction + 'claim_id' : (str) claim ID of the resulting claim + } + """ + + if outpoint is None and height is None: + raise Exception("must provide an outpoint or a height") + elif outpoint is not None: + if len(outpoint.split(":")) == 2: + txid, nout = outpoint.split(":") + nout = int(nout) + else: + raise Exception("invalid outpoint") + result = yield self.session.wallet.claim_renew(txid, nout) + else: + height = int(height) + result = yield self.session.wallet.claim_renew_all_before_expiration(height) + defer.returnValue(result) + @AuthJSONRPCServer.auth_required @defer.inlineCallbacks def jsonrpc_claim_send_to_address(self, claim_id, address, amount=None):