forked from LBRYCommunity/lbry-sdk
test+implement --comment for support_create
This commit is contained in:
parent
82f4267bf6
commit
67cce0ef7e
3 changed files with 17 additions and 4 deletions
|
@ -4080,7 +4080,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
self, claim_id, amount, tip=False,
|
self, claim_id, amount, tip=False,
|
||||||
channel_id=None, channel_name=None, channel_account_id=None,
|
channel_id=None, channel_name=None, channel_account_id=None,
|
||||||
account_id=None, wallet_id=None, funding_account_ids=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.
|
Create a support or a tip for name claim.
|
||||||
|
|
||||||
|
@ -4088,7 +4088,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
|
support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
|
||||||
[--tip] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
|
[--tip] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
|
||||||
[--channel_id=<channel_id> | --channel_name=<channel_name>]
|
[--channel_id=<channel_id> | --channel_name=<channel_name>]
|
||||||
[--channel_account_id=<channel_account_id>...]
|
[--channel_account_id=<channel_account_id>...] [--comment=<comment>]
|
||||||
[--preview] [--blocking] [--funding_account_ids=<funding_account_ids>...]
|
[--preview] [--blocking] [--funding_account_ids=<funding_account_ids>...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -4102,6 +4102,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
--account_id=<account_id> : (str) account to use for holding the transaction
|
--account_id=<account_id> : (str) account to use for holding the transaction
|
||||||
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
|
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
|
||||||
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
|
--funding_account_ids=<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
|
--preview : (bool) do not broadcast the transaction
|
||||||
--blocking : (bool) wait until transaction is in mempool
|
--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()
|
claim_address = await account.receiving.get_or_create_usable_address()
|
||||||
|
|
||||||
tx = await Transaction.support(
|
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]
|
new_txo = tx.outputs[0]
|
||||||
|
|
||||||
|
|
|
@ -925,11 +925,13 @@ class Transaction:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def support(cls, claim_name: str, claim_id: str, amount: int, holding_address: str,
|
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)
|
ledger, _ = cls.ensure_all_have_same_ledger_and_wallet(funding_accounts, change_account)
|
||||||
if signing_channel is not None:
|
if signing_channel is not None:
|
||||||
support = Support()
|
support = Support()
|
||||||
support.emoji = '👍'
|
support.emoji = '👍'
|
||||||
|
support.comment = comment
|
||||||
support_output = Output.pay_support_data_pubkey_hash(
|
support_output = Output.pay_support_data_pubkey_hash(
|
||||||
amount, claim_name, claim_id, support, ledger.address_to_hash160(holding_address)
|
amount, claim_name, claim_id, support, ledger.address_to_hash160(holding_address)
|
||||||
)
|
)
|
||||||
|
|
|
@ -574,6 +574,15 @@ class TransactionCommands(ClaimTestCase):
|
||||||
|
|
||||||
class TransactionOutputCommands(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):
|
async def test_txo_list_resolve_supports(self):
|
||||||
channel = self.get_claim_id(await self.channel_create('@identity'))
|
channel = self.get_claim_id(await self.channel_create('@identity'))
|
||||||
stream = self.get_claim_id(await self.stream_create())
|
stream = self.get_claim_id(await self.stream_create())
|
||||||
|
|
Loading…
Reference in a new issue