import click
from .decorators import online
from .main import main, config
from .ui import print_table, print_tx


@main.group()
def tools():
    """ Further tools
    """
    pass


@tools.command()
@click.pass_context
@online
@click.argument("account")
def getcloudloginkey(ctx, account):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import PasswordKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["role", "wif", "pubkey", "accounts"]]
    for role in ["owner", "active", "memo"]:
        wif = PasswordKey(account, password, role=role)
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                role,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )

    print_table(t)

import click
from .decorators import online
from .main import main, config
from .ui import print_table, print_tx


@main.group()
def tools():
    """ Further tools
    """
    pass


@tools.command()
@click.pass_context
@online
@click.argument("account")
def getcloudloginkey(ctx, account):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import PasswordKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["role", "wif", "pubkey", "accounts"]]
    for role in ["owner", "active", "memo"]:
        wif = PasswordKey(account, password, role=role)
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                role,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )

    print_table(t)


@tools.command()
@click.pass_context
@online
@click.option("--limit", default=10, type=int)
def getbrainkeys(ctx, limit):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import BrainKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["index", "wif", "pubkey", "accounts"]]
    wif = BrainKey(password)
    for i in range(limit):
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                i,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )
        next(wif)

    print_table(t)

Allow to manually generate brainkeys
Allow to manually generate brainkeys

  import click
  from .decorators import online
  from .main import main, config
  from .ui import print_table, print_tx
  
  
  @main.group()
  def tools():
      """ Further tools
      """
      pass
  
  
  @tools.command()
  @click.pass_context
  @online
  @click.argument("account")
  def getcloudloginkey(ctx, account):
      """ Return keys for cloudlogin
      """
      from bitsharesbase.account import PasswordKey
  
      password = click.prompt("Passphrase", hide_input=True).strip()
      t = [["role", "wif", "pubkey", "accounts"]]
      for role in ["owner", "active", "memo"]:
          wif = PasswordKey(account, password, role=role)
          pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])
  
          t.append(
              [
                  role,
                  str(wif.get_private_key()),
                  pubkey,
                  ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
              ]
          )
  
      print_table(t)
  
+ 
+ @tools.command()
+ @click.pass_context
+ @online
+ @click.option("--limit", default=10, type=int)
+ def getbrainkeys(ctx, limit):
+     """ Return keys for cloudlogin
+     """
+     from bitsharesbase.account import BrainKey
+ 
+     password = click.prompt("Passphrase", hide_input=True).strip()
+     t = [["index", "wif", "pubkey", "accounts"]]
+     wif = BrainKey(password)
+     for i in range(limit):
+         pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])
+ 
+         t.append(
+             [
+                 i,
+                 str(wif.get_private_key()),
+                 pubkey,
+                 ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
+             ]
+         )
+         next(wif)
+ 
+     print_table(t)
+ 
Allow to manually generate brainkeys
## Code Before:
import click
from .decorators import online
from .main import main, config
from .ui import print_table, print_tx


@main.group()
def tools():
    """ Further tools
    """
    pass


@tools.command()
@click.pass_context
@online
@click.argument("account")
def getcloudloginkey(ctx, account):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import PasswordKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["role", "wif", "pubkey", "accounts"]]
    for role in ["owner", "active", "memo"]:
        wif = PasswordKey(account, password, role=role)
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                role,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )

    print_table(t)

## Instruction:
Allow to manually generate brainkeys
## Code After:
import click
from .decorators import online
from .main import main, config
from .ui import print_table, print_tx


@main.group()
def tools():
    """ Further tools
    """
    pass


@tools.command()
@click.pass_context
@online
@click.argument("account")
def getcloudloginkey(ctx, account):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import PasswordKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["role", "wif", "pubkey", "accounts"]]
    for role in ["owner", "active", "memo"]:
        wif = PasswordKey(account, password, role=role)
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                role,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )

    print_table(t)


@tools.command()
@click.pass_context
@online
@click.option("--limit", default=10, type=int)
def getbrainkeys(ctx, limit):
    """ Return keys for cloudlogin
    """
    from bitsharesbase.account import BrainKey

    password = click.prompt("Passphrase", hide_input=True).strip()
    t = [["index", "wif", "pubkey", "accounts"]]
    wif = BrainKey(password)
    for i in range(limit):
        pubkey = format(wif.get_public_key(), ctx.bitshares.rpc.chain_params["prefix"])

        t.append(
            [
                i,
                str(wif.get_private_key()),
                pubkey,
                ctx.bitshares.wallet.getAccountFromPublicKey(pubkey) or "",
            ]
        )
        next(wif)

    print_table(t)
