From 67cce0ef7e753586707d4c58ad743221e61292fe Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 31 May 2021 20:50:15 -0300 Subject: [PATCH] test+implement --comment for support_create --- lbry/extras/daemon/daemon.py | 8 +++++--- lbry/wallet/transaction.py | 4 +++- tests/integration/blockchain/test_claim_commands.py | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index c9e372106..3011e0d42 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -4080,7 +4080,7 @@ class Daemon(metaclass=JSONRPCServerType): self, claim_id, amount, tip=False, channel_id=None, channel_name=None, channel_account_id=None, account_id=None, wallet_id=None, funding_account_ids=None, - preview=False, blocking=False): + comment=None, preview=False, blocking=False): """ Create a support or a tip for name claim. @@ -4088,7 +4088,7 @@ class Daemon(metaclass=JSONRPCServerType): support_create ( | --claim_id=) ( | --amount=) [--tip] [--account_id=] [--wallet_id=] [--channel_id= | --channel_name=] - [--channel_account_id=...] + [--channel_account_id=...] [--comment=] [--preview] [--blocking] [--funding_account_ids=...] Options: @@ -4102,6 +4102,7 @@ class Daemon(metaclass=JSONRPCServerType): --account_id= : (str) account to use for holding the transaction --wallet_id= : (str) restrict operation to specific wallet --funding_account_ids=: (list) ids of accounts to fund this transaction + --comment : (str) add a comment to the support --preview : (bool) do not broadcast the transaction --blocking : (bool) wait until transaction is in mempool @@ -4119,7 +4120,8 @@ class Daemon(metaclass=JSONRPCServerType): claim_address = await account.receiving.get_or_create_usable_address() tx = await Transaction.support( - claim.claim_name, claim_id, amount, claim_address, funding_accounts, funding_accounts[0], channel + claim.claim_name, claim_id, amount, claim_address, funding_accounts, funding_accounts[0], channel, + comment=comment ) new_txo = tx.outputs[0] diff --git a/lbry/wallet/transaction.py b/lbry/wallet/transaction.py index 4624a1420..6f47cdd13 100644 --- a/lbry/wallet/transaction.py +++ b/lbry/wallet/transaction.py @@ -925,11 +925,13 @@ class Transaction: @classmethod def support(cls, claim_name: str, claim_id: str, amount: int, holding_address: str, - funding_accounts: List['Account'], change_account: 'Account', signing_channel: Output = None): + funding_accounts: List['Account'], change_account: 'Account', signing_channel: Output = None, + comment: str = None): ledger, _ = cls.ensure_all_have_same_ledger_and_wallet(funding_accounts, change_account) if signing_channel is not None: support = Support() support.emoji = '👍' + support.comment = comment support_output = Output.pay_support_data_pubkey_hash( amount, claim_name, claim_id, support, ledger.address_to_hash160(holding_address) ) diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index c7c134cb6..9714a63a6 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -574,6 +574,15 @@ class TransactionCommands(ClaimTestCase): class TransactionOutputCommands(ClaimTestCase): + async def test_support_with_comment(self): + channel = self.get_claim_id(await self.channel_create('@identity')) + stream = self.get_claim_id(await self.stream_create()) + support = await self.support_create(stream, channel_id=channel, comment="nice!") + self.assertEqual(support['outputs'][0]['value']['comment'], "nice!") + r, = await self.txo_list(type='support') + self.assertEqual(r['txid'], support['txid']) + self.assertEqual(r['value']['comment'], "nice!") + async def test_txo_list_resolve_supports(self): channel = self.get_claim_id(await self.channel_create('@identity')) stream = self.get_claim_id(await self.stream_create())