def create_account(balance, block_count=1, complete=False, confirm=False): private_key = generate_seed() account_id = get_account_id(private_key=private_key) account = Account( account_id=account_id, public_key=get_account_public_key(private_key=private_key), private_key=private_key, source=AccountSource.PRIVATE_KEY, representative=get_account_id(public_key=generate_seed()) ) block_amount = int(balance / block_count) for _ in range(0, block_count): account.receive_block( pocketable_block_factory( account_id=account_id, amount=block_amount ) ) if complete: block = account.blocks[-1] block.sign(private_key=account.private_key) block.solve_work(difficulty=TEST_DIFFICULTY) if confirm: block.confirmed = True account.update_confirmed_head() return account
def create_account(account_id=None): if not account_id: account_id = get_account_id(public_key=generate_seed()) account = Account( account_id=account_id, source=AccountSource.WATCHING) return account
def create_work_unit(account_id=None, difficulty=None): if not difficulty: difficulty = to_hex(10000, 16) block = RawBlock( block_type="state", account=(account_id or get_account_id(public_key=generate_seed())), previous=None, representative=get_account_id(public_key="0" * 64), balance=0, link=generate_seed(), difficulty=difficulty, verify=False) work_unit = WorkUnit(account_id=block.account, block_hash=block.block_hash, work_block_hash=block.work_block_hash, difficulty=block.difficulty) return work_unit
def create_link_block(account_id, amount): sending_private_key = generate_seed() sending_account_id = get_account_id(private_key=sending_private_key) block = RawBlock( block_type="send", account=sending_account_id, previous=generate_seed().upper(), destination=account_id, balance=amount + random.randint(-amount, 2**110) ) block.sign(sending_private_key) block.solve_work(difficulty=TEST_DIFFICULTY) link_block = LinkBlock( block_data=block.to_dict(), amount=amount, timestamp=Timestamp( date=time.time(), source=TimestampSource.WALLET ) ) return link_block
def create_account(private_key=None): if not private_key: private_key = generate_seed() public_key = get_account_public_key(private_key=private_key) account_id = get_account_id(public_key=public_key) account = Account( account_id=account_id, public_key=public_key, private_key=private_key, source=AccountSource.PRIVATE_KEY) return account
def create_wallet( server, wallet_path: FilePathParam(exists=False), seed: SecureStrOption, encrypt_secrets: BoolOption, encrypt_wallet: BoolOption, passphrase: SecureStrOption, gap_limit: IntRangeOption(minimum=0, maximum=10000, default=20), key_iteration_count: IntRangeOption( default=get_default_key_iteration_count, minimum=1, maximum=2**32 )): if os.path.exists(wallet_path): raise WalletExists if not seed: logger.info("Seed not provided, generating one automatically.") seed = generate_seed() validate_seed(seed) wallet = Wallet( properties=WalletProperties( seed_algorithm=WalletSeedAlgorithm.NANO, seed=seed, gap_limit=gap_limit ) ) wallet.refill_accounts() if encrypt_secrets or encrypt_wallet: if not passphrase: raise MissingPassphrase wallet.change_passphrase( passphrase=passphrase, encrypt_secrets=encrypt_secrets, encrypt_wallet=encrypt_wallet, key_iteration_count=key_iteration_count) wallet.save(wallet_path) return StdioResult( { "message": "Saved wallet to {}".format(wallet_path), "wallet_encrypted": wallet.encryption.wallet_encrypted, "secrets_encrypted": wallet.encryption.secrets_encrypted } )
def test_work_local_multiple(local_work_plugin_factory, work_unit_factory): # Enqueue multiple PoW jobs and ensure they're all completed account_ids = [ get_account_id(private_key=generate_seed()) for _ in range(0, 100) ] work_plugin = local_work_plugin_factory(threads=8) work_plugin.add_work_units_to_solve([ work_unit_factory(account_id=account_id) for account_id in account_ids ], network_difficulty=to_hex(10000, 16)) work_units = work_plugin.work_units # The underlying queue is a set, so the exact amount of results # should be 100 even if more valid PoWs were found wait_for(lambda: count_solved_units(work_units) == 100, timeout=5) for work_unit in work_units.values(): account_ids.remove(work_unit.account_id)
def create_wallet(balance=0, seed=None, confirmed=False): if not seed: seed = generate_seed() wallet = Wallet( properties=WalletProperties( seed=seed, seed_algorithm=WalletSeedAlgorithm.NANO, gap_limit=20 ) ) wallet.refill_accounts() if balance > 0: account = wallet.accounts[0] block = account.receive_block( pocketable_block_factory( account_id=account.account_id, amount=balance ) ) if confirmed: block.sign(account.get_secret("private_key")) block.solve_work(difficulty=TEST_DIFFICULTY) block.confirmed = True account.update_confirmed_head() if is_encrypted_test: key_iteration_count = 200 wallet.change_passphrase( passphrase="password", encrypt_wallet=True, encrypt_secrets=True, key_iteration_count=key_iteration_count ) wallet.lock() assert not wallet.secrets_unlocked assert not wallet.secret_key assert wallet.encryption.secrets_encrypted return wallet
def create_wallet_properties(): return WalletProperties( seed=generate_seed(), seed_algorithm=WalletSeedAlgorithm.NANO, gap_limit=20 )
from nanolib import generate_seed, generate_account_id import string, random import requests def accounts_balances(accounts): data = {"action":"accounts_balances","accounts": accounts} response = requests.post('http://api.nanex.cc/', json=data) return response.json() while True: seeds = [] adresses = [] for n in range(100): seed = generate_seed() account = generate_account_id(seed, 0).replace("xrb", "nano") seeds.append(seed) adresses.append(account) all_balances = accounts_balances(adresses)\ try: bals = all_balances["balances"] except: continue for address in bals: result = f"Account: {address} || Seed: {seeds[adresses.index(address)]} || Balances: (Balance: {bals[address]['balance']}, Pending: {bals[address]['pending']})" if int(bals[address]['balance']) > 0 or int(bals[address]['pending']) > 0: with open('wallets.txt', 'a') as arq: