diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d48ba536..c11518b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ at anytime. * * +### Added + * Added `claim_send_tip`, a command to tip the owner of a claim via a support transaction + * + ### Fixed * * diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index c5a0d79bd..c7de21d29 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -976,6 +976,15 @@ class Wallet(object): d.addCallback(lambda claim_out: _parse_support_claim_out(claim_out)) return d + @defer.inlineCallbacks + def tip_claim(self, claim_id, amount): + claim_out = yield self._tip_claim(claim_id, amount) + if claim_out: + result = self._process_claim_out(claim_out) + defer.returnValue(result) + else: + raise Exception("failed to send tip of %f to claim id %s" % (amount, claim_id)) + def get_block_info(self, height): d = self._get_blockhash(height) return d @@ -1085,6 +1094,9 @@ class Wallet(object): def _support_claim(self, name, claim_id, amount): return defer.fail(NotImplementedError()) + def _tip_claim(self, claim_id, amount): + return defer.fail(NotImplementedError()) + def _do_send_many(self, payments_to_send): return defer.fail(NotImplementedError()) @@ -1372,6 +1384,14 @@ class LBRYumWallet(Wallet): claim_out = yield self._broadcast_claim_transaction(tx) defer.returnValue(claim_out) + @defer.inlineCallbacks + def _tip_claim(self, claim_id, amount): + log.debug("Tip %s %f", claim_id, amount) + broadcast = False + tx = yield self._run_cmd_as_defer_succeed('sendwithsupport', claim_id, amount, broadcast) + claim_out = yield self._broadcast_claim_transaction(tx) + defer.returnValue(claim_out) + @defer.inlineCallbacks def _broadcast_claim_transaction(self, claim_out): if 'success' not in claim_out: diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index dfb67cbbe..f6665ac6a 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -1909,6 +1909,29 @@ class Daemon(AuthJSONRPCServer): self.analytics_manager.send_claim_action('new_support') defer.returnValue(result) + @AuthJSONRPCServer.auth_required + @defer.inlineCallbacks + def jsonrpc_claim_send_tip(self, claim_id, amount): + """ + Send a tip to the owner of a claim specified by uri. A tip is a claim support + where the recipient of the support is the claim address for the claim being supported. + + Usage: + claim_send_tip ( | --claim_id=) ( | --amount=) + + Return: + (dict) Dictionary containing the result of the support + { + txid : (str) txid of resulting support claim + nout : (int) nout of the resulting support claim + fee : (float) fee paid for the transaction + } + """ + + result = yield self.session.wallet.tip_claim(claim_id, amount) + self.analytics_manager.send_claim_action('new_support') + defer.returnValue(result) + @AuthJSONRPCServer.auth_required @defer.inlineCallbacks def jsonrpc_claim_send_to_address(self, claim_id, address, amount=None):