def execute(self, args, output): convex = self.load_convex(args.url) key_pair = self.import_key_pair(args) if key_pair is None: key_pair = KeyPair() logger.debug('creating account') account = convex.create_account(key_pair) if args.topup: logger.debug('auto topup of account balance') convex.topup_account(account) if args.name: logger.debug(f'registering account name {args.name}') convex.topup_account(account) account = convex.register_account_name(args.name, account) if args.password: password = args.password else: password = secrets.token_hex(32) values = { 'password': password, 'address': account.address, 'public_key': key_pair.public_key, 'keyfile': key_pair.export_to_text(password), 'keywords': key_pair.export_to_mnemonic, 'balance': convex.get_balance(account) } if account.name: values['name'] = account.name output.set_values(values) output.add_line_values(values)
def test_account_api_multi_create_account(convex_url): convex = API(convex_url) key_pair = KeyPair() account_1 = convex.create_account(key_pair) assert(account_1) account_2 = convex.create_account(key_pair) assert(account_2) assert(account_1.public_key == account_1.public_key) assert(account_1.public_key == account_2.public_key) assert(account_1.is_address) assert(account_1.address != account_2.address)
def execute(self, args, output): convex = self.load_convex(args.url) key_pair = self.import_key_pair(args) if key_pair is None: key_pair = KeyPair() logger.debug('creating account') account = convex.create_account(key_pair) if args.topup: logger.debug('auto topup of account balance') for counter in range(4): convex.request_funds(DEFAULT_FUND_AMOUNT, account) if args.name: logger.debug(f'registering account name {args.name}') convex.topup_account(account) account = convex.register_account_name(args.name, account) if args.password: password = args.password else: password = secrets.token_hex(32) balance = convex.get_balance(account) stake_amount = math.floor(balance * 0.98) create_peer_command = f'(create-peer {account.key_pair.public_key} {stake_amount} )' convex.send(create_peer_command, account) values = { 'password': password, 'address': account.address, 'public_key': key_pair.public_key, 'keyfile': key_pair.export_to_text(password), 'keywords': key_pair.export_to_mnemonic, 'balance': convex.get_balance(account), 'stake': stake_amount, } if account.name: values['name'] = account.name output.set_values(values) output.add_line_values(values)
def execute(self, args: Any, output: Any) -> None: network = self.get_network(args.url) key_pair = None if args.password and args.keyfile: key_pair = KeyPair.import_from_file(args.keyfile, args.password) else: key_pair = KeyPair() account = network.create_account(key_pair) logger.debug(f'create new account {account.address}') if args.keyfile and not os.path.exists(args.keyfile): logger.debug(f'writing key file to {args.keyfile}') account.key_pair.export_to_file(args.keyfile, args.password) else: logger.debug('writing key file to ouptut') output.add_line(account.key_pair.export_to_text(args.password)) output.add_line(account.address) output.set_value('public_key', account.public_key) output.set_value('export_key', account.key_pair.export_to_text(args.password)) output.set_value('address', account.address)
def test_account_api_create_account(convex_url): convex = API(convex_url) key_pair = KeyPair() result = convex.create_account(key_pair) assert(result)