From 72acfa1e0cc3831094fe49a7b9da8c67ddfdec64 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 8 Aug 2016 02:32:56 -0400 Subject: [PATCH] add support_claim --- lbrynet/core/LBRYWallet.py | 25 +++++++++++++++++++++++++ lbrynet/lbrynet_daemon/LBRYDaemon.py | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 46be98547..c5c9b49f4 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -482,6 +482,9 @@ class LBRYWallet(object): dl.addCallback(abandon) return dl + def support_claim(self, name, claim_id, amount): + return self._support_claim(name, claim_id, amount) + def get_tx(self, txid): d = self._get_raw_tx(txid) d.addCallback(self._get_decoded_tx) @@ -668,6 +671,9 @@ class LBRYWallet(object): def _update_name(self, name, txid, value, amount): return defer.fail(NotImplementedError()) + def _support_claim(self, name, claim_id, amount): + return defer.fail(NotImplementedError()) + def _do_send_many(self, payments_to_send): return defer.fail(NotImplementedError()) @@ -803,6 +809,9 @@ class LBRYcrdWallet(LBRYWallet): def _update_name(self, name, txid, value, amount): return threads.deferToThread(self._update_name_rpc, txid, value, amount) + def _support_claim(self, name, claim_id, amount): + return threads.deferToThread(self._support_claim_rpc, name, claim_id, amount) + def _get_claims_for_name(self, name): return threads.deferToThread(self._get_claims_for_name_rpc, name) @@ -981,6 +990,11 @@ class LBRYcrdWallet(LBRYWallet): elif 'message' in e.error: raise ValueError(e.error['message']) + @_catch_connection_error + def _support_claim_rpc(self, name, claim_id, amount): + rpc_conn = self._get_rpc_conn() + return rpc_conn.supportclaim(name, claim_id, amount) + @_catch_connection_error def _get_num_addresses_rpc(self): rpc_conn = self._get_rpc_conn() @@ -1233,6 +1247,17 @@ class LBRYumWallet(LBRYWallet): d.addCallback(self._broadcast_transaction) return d + def _support_claim(self, name, claim_id, amount): + def _send_support(d, a, n, c): + cmd = known_commands['supportclaim'] + func = getattr(self.cmd_runner, cmd.name) + d = threads.deferToThread(func, d, a, n, c) + return d + d = self.get_new_address() + d.addCallback(lambda address: _send_support(address, amount, name, claim_id)) + d.addCallback(self._broadcast_transaction) + return d + def _broadcast_transaction(self, raw_tx): log.info("Broadcast: %s" % str(raw_tx)) cmd = known_commands['broadcast'] diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 7134a4a53..d6987aa2c 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -1979,6 +1979,25 @@ class LBRYDaemon(jsonrpc.JSONRPC): return d + def jsonrpc_support_claim(self, p): + """ + Support a name claim + + Args: + 'name': name + 'claim_id': claim id of claim to support + 'amount': amount to support by + Return: + txid + """ + + name = p['name'] + claim_id = p['claim_id'] + amount = p['amount'] + d = self.session.wallet.support_claim(name, claim_id, amount) + d.addCallback(lambda r: self._render_response(r, OK_CODE)) + return d + def jsonrpc_get_name_claims(self): """ Get my name claims