# Buggy code
async def jsonrpc_support_create(
    self,
    claim_id,
    amount,
    tip=False,
    account_id=None,
    wallet_id=None,
    funding_account_ids=None,
    preview=False,
    blocking=False,
):
    """
    Create a support or a tip for name claim.

    Usage:
        support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
                       [--tip] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
                       [--preview] [--blocking] [--funding_account_ids=<funding_account_ids>...]

    Options:
        --claim_id=<claim_id>     : (str) claim_id of the claim to support
        --amount=<amount>         : (decimal) amount of support
        --tip                     : (bool) send support to claim owner, default: false.
        --account_id=<account_id> : (str) account to use for holding the transaction
        --wallet_id=<wallet_id>   : (str) restrict operation to specific wallet
      --funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
        --preview                 : (bool) do not broadcast the transaction
        --blocking                : (bool) wait until transaction is in mempool

    Returns: {Transaction}
    """
    wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
    assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first."
    funding_accounts = wallet.get_accounts_or_all(funding_account_ids)
    amount = self.get_dewies_or_error("amount", amount)
    claim = await self.ledger.get_claim_by_claim_id(wallet.accounts, claim_id)
    claim_address = claim.get_address(self.ledger)
    if not tip:
        account = wallet.get_account_or_default(account_id)
        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],
    )

    if not preview:
        await self.broadcast_or_release(tx, blocking)
        await self.storage.save_supports(
            {
                claim_id: [
                    {
                        "txid": tx.id,
                        "nout": tx.position,
                        "address": claim_address,
                        "claim_id": claim_id,
                        "amount": dewies_to_lbc(amount),
                    }
                ]
            }
        )
        await self.analytics_manager.send_claim_action("new_support")
    else:
        await self.ledger.release_tx(tx)

    return tx


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
async def jsonrpc_support_create(
    self,
    claim_id,
    amount,
    tip=False,
    account_id=None,
    wallet_id=None,
    funding_account_ids=None,
    preview=False,
    blocking=False,
):
    """
    Create a support or a tip for name claim.

    Usage:
        support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
                       [--tip] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
                       [--preview] [--blocking] [--funding_account_ids=<funding_account_ids>...]

    Options:
        --claim_id=<claim_id>     : (str) claim_id of the claim to support
        --amount=<amount>         : (decimal) amount of support
        --tip                     : (bool) send support to claim owner, default: false.
        --account_id=<account_id> : (str) account to use for holding the transaction
        --wallet_id=<wallet_id>   : (str) restrict operation to specific wallet
      --funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
        --preview                 : (bool) do not broadcast the transaction
        --blocking                : (bool) wait until transaction is in mempool

    Returns: {Transaction}
    """
    wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
    assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first."
    funding_accounts = wallet.get_accounts_or_all(funding_account_ids)
    amount = self.get_dewies_or_error("amount", amount)
    claim = await self.ledger.get_claim_by_claim_id(wallet.accounts, claim_id)
    claim_address = claim.get_address(self.ledger)
    if not tip:
        account = wallet.get_account_or_default(account_id)
        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],
    )

    if not preview:
        await self.broadcast_or_release(tx, blocking)
        await self.storage.save_supports(
            {
                claim_id: [
                    {
                        "txid": tx.id,
                        "nout": tx.position,
                        "address": claim_address,
                        "claim_id": claim_id,
                        "amount": dewies_to_lbc(amount),
                    }
                ]
            }
        )
        self.component_manager.loop.create_task(
            self.analytics_manager.send_claim_action("new_support")
        )
    else:
        await self.ledger.release_tx(tx)

    return tx