add support_claim

This commit is contained in:
Jack 2016-08-08 02:32:56 -04:00
parent 02cd8b9a44
commit 72acfa1e0c
2 changed files with 44 additions and 0 deletions

View file

@ -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']

View file

@ -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